23.11 Collaboration
23.11.7 Nonconflicted commits to the same file
Go through the whole process again, but this time, both of you should make changes to a single file, but make sure that you don’t touch the sameline. Again, the merge should work as before:
In [23]: %%writefile Wales.md Mountains In Wales ================== * Tryfan * Snowdon Overwriting Wales.md In [24]: %%bash git diff
diff --git a/Wales.md b/Wales.md index 784f1df..e2ca555 100644 --- a/Wales.md +++ b/Wales.md @@ -1,9 +1,5 @@ Mountains In Wales ================== -* Pen y Fan * Tryfan -* Snowdon -* Glyder Fawr -* Fan y Big -* Cadair Idris
\ No newline at end of file +* Snowdon
\ No newline at end of file
In [25]: %%bash
git commit -am "Translating from the Welsh" [master 4b2dd03] Translating from the Welsh
1 file changed, 1 insertion(+), 5 deletions(-)
In [26]: %%bash
git log --oneline
4b2dd03 Translating from the Welsh 9ca6f1d Add Scotland
ff7d924 Add a makefile and ignore generated files 3f34a69 Add Pennines
670f9d0 Commit Aonach onto master branch
3203223 Merge branch ’master’ of github.com:UCL/github-example 6635705 Add Glyder
c8cbfb6 Add another Beacon
d6549a0 Merge branch ’master’ of github.com:UCL/github-example b4f45f8 Translating from the Welsh
b93da7b Add a beacon
bebd994 Merge branch ’master’ of github.com:UCL/github-example 50ea306 Add wales
ddac17c Add Scotland 7dc0ebe Add Helvellyn
dde2ca8 Include lakes in the scope 37dc94c Add lakeland
dc4aa48 Revert "Add a lie about a mountain" e750838 Change title
006b560 Add a lie about a mountain
278d18c First commit of discourse on UK topography
In [27]: os.chdir(working_dir)
In [28]: %%writefile Wales.md Mountains In Wales ==================
* Pen y Fan * Tryfan * Snowdon Overwriting Wales.md
In [29]: %%bash
git commit -am "Add a beacon" [master 1e4351d] Add a beacon
1 file changed, 2 insertions(+), 1 deletion(-)
In [30]: %%bash
git log --oneline 1e4351d Add a beacon 35228fd Add wales fa37aa5 Add Helvellyn
8eeb1aa Include lakes in the scope 9d7c86a Add lakeland
b7b8924 Revert "Add a lie about a mountain" 201110e Change title
47f2a5c Add a lie about a mountain
1561abf First commit of discourse on UK topography
In [31]: %%bash
git push
warning: push.default is unset; its implicit value has changed in Git 2.0 from ’matching’ to ’simple’. To squelch this message and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use: git config --global push.default simple
When push.default is set to ’matching’, git will push local branches to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative ’simple’ behavior, which only pushes the current branch to the corresponding remote branch that ’git pull’ uses to update the current branch.
See ’git help config’ and search for ’push.default’ for further information. (the ’simple’ mode was introduced in Git 1.7.11. Use the similar mode
’current’ instead of ’simple’ if you sometimes use older versions of Git) fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use git push --set-upstream origin master
Switching back to the other partner. . .
In [33]: %%bash
git push
warning: push.default is unset; its implicit value has changed in Git 2.0 from ’matching’ to ’simple’. To squelch this message and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use: git config --global push.default simple
When push.default is set to ’matching’, git will push local branches to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative ’simple’ behavior, which only pushes the current branch to the corresponding remote branch that ’git pull’ uses to update the current branch.
See ’git help config’ and search for ’push.default’ for further information. (the ’simple’ mode was introduced in Git 1.7.11. Use the similar mode
’current’ instead of ’simple’ if you sometimes use older versions of Git) ERROR: Permission to UCL/github-example.git denied to ucl-rsd-ci.
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
In [34]: %%bash
git pull Already up-to-date.
In [35]: %%bash
git push
warning: push.default is unset; its implicit value has changed in Git 2.0 from ’matching’ to ’simple’. To squelch this message and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use: git config --global push.default simple
When push.default is set to ’matching’, git will push local branches to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative ’simple’ behavior, which only pushes the current branch to the corresponding remote branch that ’git pull’ uses to update the current branch.
See ’git help config’ and search for ’push.default’ for further information. (the ’simple’ mode was introduced in Git 1.7.11. Use the similar mode
’current’ instead of ’simple’ if you sometimes use older versions of Git) ERROR: Permission to UCL/github-example.git denied to ucl-rsd-ci.
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
In [36]: %%bash
git log --oneline --graph * 4b2dd03 Translating from the Welsh * 9ca6f1d Add Scotland
* ff7d924 Add a makefile and ignore generated files * 3f34a69 Add Pennines
* 670f9d0 Commit Aonach onto master branch
* 3203223 Merge branch ’master’ of github.com:UCL/github-example |\
| * c8cbfb6 Add another Beacon * | 6635705 Add Glyder
|/
* d6549a0 Merge branch ’master’ of github.com:UCL/github-example |\
| * b93da7b Add a beacon
* | b4f45f8 Translating from the Welsh |/
* bebd994 Merge branch ’master’ of github.com:UCL/github-example |\
| * ddac17c Add Scotland * | 50ea306 Add wales |/
* 7dc0ebe Add Helvellyn
* dde2ca8 Include lakes in the scope * 37dc94c Add lakeland
* dc4aa48 Revert "Add a lie about a mountain" * e750838 Change title
* 006b560 Add a lie about a mountain
* 278d18c First commit of discourse on UK topography
In [37]: os.chdir(working_dir)
In [38]: %%bash
git pull
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> master
In [39]: %%bash
git log --graph --oneline * 1e4351d Add a beacon
* 35228fd Add wales * fa37aa5 Add Helvellyn
* 8eeb1aa Include lakes in the scope * 9d7c86a Add lakeland
* b7b8924 Revert "Add a lie about a mountain" * 201110e Change title
* 47f2a5c Add a lie about a mountain
* 1561abf First commit of discourse on UK topography
In [40]: message="""
participant Sue as S
participant "Sue’s repo" as SR participant "Shared remote" as M participant "Jim’s repo" as JR participant Jim as J
note left of S: git clone M->SR: fetch commits
SR->S: working directory as at latest commit note left of S: edit Scotland.md
note right of J: edit Wales.md
note left of S: git commit -am "Add scotland" S->SR: create commit with Scotland file note right of J: git commit -am "Add wales" J->JR: create commit with Wales file
note left of S: git push
SR->M: update remote with changes note right of J: git push
JR-->M: !Rejected change note right of J: git pull
M->JR: Pull in Sue’s last commit, merge histories JR->J: Add Scotland.md to working directory note right of J: git push
JR->M: Transfer merged history to remote """
from wsd import wsd
%matplotlib inline wsd(message)