Skip to content
Snippets Groups Projects
Commit 0f9b330e authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

Merge branch 'advanced-training' into 'develop'

minor changes for advanced training

See merge request !46
parents 54fa54bb 7dc7f6ee
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ $ git status ...@@ -26,7 +26,7 @@ $ git status
* Use `git commit --amend` to change the commit * Use `git commit --amend` to change the commit
Alternatively, you can use the `-m` flag to edit only the commit message: * Alternatively, you can use the `-m` flag to edit only the commit message:
```bash ```bash
$ git commit --amend -m "Add title" $ git commit --amend -m "Add title"
``` ```
......
# Cherry-picking # Cherry-picking
* Cherry-picking allows to pick one (or more) specific commits from a list of commits. * Cherry-picking allows to pick one (or more) specific commits from a list of commits.
* Only the chosen commit(s) are picked, not everything up to that commit. * Only the chosen commit(s) are picked, not everything up to that commit.
<div style="top: 8em; left: 25%; position: absolute;"> <div style="top: 8em; left: 25%; position: absolute;">
......
# Rebasing (1) # Rebasing (1)
* `git rebase` enables to forward your commits * `git rebase` enables to shift forward your commits in time
* Move/combine a sequence of commits to a new base commit * Move/combine a sequence of commits to a new base commit
* Avoid discrepancies when multiple people work on the same project * Avoid discrepancies when multiple people work on the same project
* Linear git history (no merge commits) * Linear git history (no merge commits)
* Rebasing is like saying, “I want to base my changes on what everybody has already done.” * Rebasing is like saying, “I want to base my changes on what everybody has already done.”
Imagine the following situation: Imagine the following situation:
<div style="top: 10em; left: 30%; position: absolute;"> <div style="top: 14em; left: 25%; position: absolute;">
<img src="slides/img/beforeRebase.png" height="500px"> <img src="slides/img/beforeRebase.png" height="500px">
</div> </div>
* There are commits on `develop` that aren't in `myBranch`.
# Rebasing (2) # Rebasing (2)
* `myBranch` is several commits ahead of `develop`. * After rebase, the commits in the `myBranch` branch will be place on top of `develop`.
* Commits implemented into `develop` that aren't in `myBranch`.
<div style="top: 10em; left: 30%; position: absolute;"> <div style="top: 5em; left: 25%; position: absolute;">
<img src="slides/img/afterRebase.png" height="500px"> <img src="slides/img/afterRebase.png" height="500px">
</div> </div>
...@@ -26,7 +27,7 @@ Imagine the following situation: ...@@ -26,7 +27,7 @@ Imagine the following situation:
# Example (1): # Example (1):
* A merge request against `develop` is still open. Repository maintainer: review, and merge it. * A merge request against `develop` is still open. **Repository maintainer: review, and merge it.**
* Create a file in your branch `myBranch` * Create a file in your branch `myBranch`
```bash ```bash
...@@ -147,4 +148,9 @@ $ pick 1234567 add william to attendee list ...@@ -147,4 +148,9 @@ $ pick 1234567 add william to attendee list
$ squash abcdef0 add roberta to attendee list $ squash abcdef0 add roberta to attendee list
``` ```
* This will create a commit with both modified files, with the commit message being a combination of the two commit messages. * This will create a commit with both modified files, with the commit message being a combination of the two commit messages.
\ No newline at end of file
* Push the changes to `myBranch` with `-f`:
```bash
$ git push origin myBranch -f
```
\ No newline at end of file
...@@ -23,7 +23,7 @@ $ git commit -m "add biography for Firstname Lastname" ...@@ -23,7 +23,7 @@ $ git commit -m "add biography for Firstname Lastname"
$ git push origin myBranch $ git push origin myBranch
``` ```
* Check the commits, copy the `SHA1` of the second last commit: * Check the commits, copy the `SHA1` of the **second last** commit:
```bash ```bash
$ git log $ git log
``` ```
...@@ -32,7 +32,7 @@ $ git log ...@@ -32,7 +32,7 @@ $ git log
# Example: Hard reset of a branch (2) # Example: Hard reset of a branch (2)
* Use the `reset --hard` command in order to undo the commit with `<SHA1>: * Use the `reset --hard` command in order to undo the commit with `<SHA1>`:
```bash ```bash
$ git reset --hard <SHA1> $ git reset --hard <SHA1>
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment