You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/05-resolving-conflicts.md
+98-10Lines changed: 98 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,40 +28,114 @@ To keep the conflict on the code — not between people — we’ll practice bre
28
28
29
29
### Exercise 05.1
30
30
31
-
Exercise with your pair to add content to you shared repository in two different branches. Learn how to update your working branch with contents of the updated remote.
31
+
Exercise with your pair to add content to you shared repository in the default branch. You can do so if both of you have at least maintainer rights to the repository. Learn how to update your working area with contents of the updated remote.
32
+
33
+
One of you makes a new local edits. Meanwhile, the other one updates the remote default branch with new files.
32
34
33
-
Use `git rebase`.
34
35
35
36
:::::::::::::::: solution
36
37
37
-
See https://git-scm.com/docs/git-rebase
38
+
If you try to push, you will see a message like this:
39
+
40
+
```
41
+
! [rejected] main -> main (fetch first)
42
+
error: failed to push some refs to 'gitlab.com:katilp/tutorial-test.git'
43
+
hint: Updates were rejected because the remote contains work that you do not
44
+
hint: have locally. This is usually caused by another repository pushing to
45
+
hint: the same ref. If you want to integrate the remote changes, use
46
+
hint: 'git pull' before pushing again.
47
+
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
48
+
```
49
+
50
+
A bare `git pull`, as suggested in the message most likely gives:
51
+
52
+
```
53
+
2f8c69a..d32176b main -> origin/main
54
+
hint: You have divergent branches and need to specify how to reconcile them.
55
+
hint: You can do so by running one of the following commands sometime before
56
+
hint: your next pull:
57
+
hint:
58
+
hint: git config pull.rebase false # merge
59
+
hint: git config pull.rebase true # rebase
60
+
hint: git config pull.ff only # fast-forward only
61
+
hint:
62
+
hint: You can replace "git config" with "git config --global" to set a default
63
+
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
64
+
hint: or --ff-only on the command line to override the configured default per
65
+
hint: invocation.
66
+
```
67
+
68
+
Get the remote changes with
69
+
70
+
```
71
+
git pull --rebase
72
+
```
73
+
74
+
and then push your updates.
75
+
76
+
Did this work in your case?
38
77
39
78
:::::::::::::::::::::::::
40
79
:::::::::::::::::::::::::::::::::::::::::::::::
41
80
81
+
::::::::::::::::::::::::::::::::::::: challenge
42
82
43
-
::::::::::::::::::::::::::::::::::::: callout
44
-
### Remember to update your local main/master branch!!!
83
+
### Exercise 05.2
84
+
85
+
Exercise with your pair to add content to you shared repository in two different branches. Learn how to update your working branch with contents of the updated remote.
86
+
87
+
One of you makes a new local edits to a local working branch. Meanwhile, the other one updates the remote default branch with new files.
88
+
89
+
90
+
:::::::::::::::: solution
91
+
92
+
Create a new branch, make edits, and push them to the shared repository with
93
+
94
+
```
95
+
git push origin <your branch name>
96
+
```
45
97
46
-
Always remember to update your local default branch.
98
+
Then make a merge request from the GitLab Web UI.
99
+
100
+
If the branches diverge you will see a message about it and you can click on "Rebase source branch" and accept
0 commit comments