Skip to content

Commit 9d51988

Browse files
committed
Adding one more exercise for section branches
1 parent 2123ab7 commit 9d51988

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

docs/branches-exercises.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,45 @@ Start by making sure you are in the directory `git_materials/5.branches/4.rebase
124124
$ git log --oneline --abbrev-commit --all --graph
125125
```
126126

127-
## 5.
127+
## 5. Rebase two local branches resulting in a conflict
128+
129+
!!! note
130+
131+
This exercise will again let you rebase two branches, using the command `git rebase`. In this case the rebase will fail.
132+
133+
**Situation:** In the branch "metric" we change the recipe to use the metric system for measurements. Then we switch back to the "master" branch and **add some coffee** to that version of the recipe.
134+
135+
Start by making sure you are in the directory `git_materials/5.branches/5.rebase-bad/recipes`.
136+
137+
1. Check status and history with `git status` and `git graph` or `git log` first, including with the following flags to `git log`:
138+
139+
```
140+
$ git log --oneline --abbrev-commit --all --graph
141+
```
142+
2. Try to rebase the "master" branch to the "metric" branch using the `git rebase` command and see that a conflict happens.
143+
144+
NOTE: Remember to check with `git branch` to find out if you are on the right branch before trying to rebase.
145+
146+
You will get an error more or less similar to this:
147+
148+
```
149+
$ git rebase master
150+
First, rewinding head to replay your work on top of it...
151+
Applying: Change from imperial units to metric units.
152+
Using index info to reconstruct a base tree...
153+
M cakerecipe.txt
154+
Falling back to patching base and 3-way merge...
155+
Auto-merging cakerecipe.txt
156+
CONFLICT (content): Merge conflict in cakerecipe.txt
157+
error: Failed to merge in the changes.
158+
Patch failed at 0001 Change from imperial units to metric units.
159+
Use 'git am --show-current-patch' to see the failed patch
160+
161+
Resolve all conflicts manually, mark them as resolved with
162+
"git add/rm <conflicted_files>", then run "git rebase --continue".
163+
You can instead skip this commit: run "git rebase --skip".
164+
To abort and get back to the state before "git rebase", run "git rebase --abort".
165+
```
166+
<br>
167+
3. Use `git log` (with the above flags) or `git graph`and `git status` to see where the problems are. See if you can fix the conflict and then reattempt the rebase.
128168

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ markdown_extensions:
8787
- pymdownx.inlinehilite
8888
- pymdownx.snippets
8989
- admonition
90+
# - pymdownx.blocks.admonition
9091
- pymdownx.arithmatex:
9192
generic: true
9293
- footnotes

0 commit comments

Comments
 (0)