Git pull with rebase

U1:

git clone https://github.com/bmwieczorek/my-git.git
cd my-git
echo "U1: created new file.txt" > file.txt
git add file.txt
git commit -m "U1: created new file.txt"
git push origin master
echo "U1: appended once file.txt" >> file.txt
git commit -am "U1: appended once file.txt"
git log
 commit e4c4df7201eea9b4deeff7451c2090d956640907
 Date: Sat Feb 6 14:21:05 2016 +0100
  U1: appended once file.txt
 commit 50ab9d12ec08854737a8d66c67647acc4af7e7b1
 Date: Sat Feb 6 14:21:02 2016 +0100
  U1: created new file.txt

U2
git clone https://github.com/bmwieczorek/my-git.git
cd my-git
echo “U2: appended once file.txt” >> file.txt
git commit -am “U2: appended once file.txt”
git push origin master
git log
commit d7c88b0c87aa9f0993924a5fd0ded8f52f2fe844
Date: Sat Feb 6 14:21:59 2016 +0100
U2: appended once file.txt
commit 50ab9d12ec08854737a8d66c67647acc4af7e7b1
Date: Sat Feb 6 14:21:02 2016 +0100
U1: created new file.txt

U1
git pull –rebase

First, rewinding head to replay your work on top of it…
Applying: U1: appended once file.txt
Using index info to reconstruct a base tree…
M file.txt
Falling back to patching base and 3-way merge…
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
error: Failed to merge in the changes.
Patch failed at 0001 U1: appended once file.txt
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run “git rebase –continue”.
If you prefer to skip this patch, run “git rebase –skip” instead.
To check out the original branch and stop rebasing, run “git rebase –abort”.

git status
rebase in progress; onto d7c88b0
You are currently rebasing branch ‘master’ on ‘d7c88b0’.
(fix conflicts and then run “git rebase –continue”)
(use “git rebase –skip” to skip this patch)
(use “git rebase –abort” to check out the original branch)
Unmerged paths:
(use “git reset HEAD <file>…” to unstage)
(use “git add <file>…” to mark resolution)
both modified: file.txt
no changes added to commit (use “git add” and/or “git commit -a”)

git log
commit d7c88b0c87aa9f0993924a5fd0ded8f52f2fe844
Date: Sat Feb 6 14:21:59 2016 +0100
U2: appended once file.txt
commit 50ab9d12ec08854737a8d66c67647acc4af7e7b1
Date: Sat Feb 6 14:21:02 2016 +0100
U1: created new file.txt

cat file.txt
U1: created new file.txt
<<<<<<< d7c88b0c87aa9f0993924a5fd0ded8f52f2fe844
U2: appended once file.txt
=======
U1: appended once file.txt
>>>>>>> U1: appended once file.txt

cat file.txt | egrep -v ‘<<<|>>>|===’ > file.txt # resolve conflict
cat file.txt
U1: created new file.txt
U2: appended once file.txt
U1: appended once file.txt

git add file.txt

git rebase –continue
Applying: U1: appended once file.txt

git log
commit 36876c0914fc56eeb86aeb5fb274f02323099b32
Date: Sat Feb 6 14:21:05 2016 +0100
U1: appended once file.txt
commit d7c88b0c87aa9f0993924a5fd0ded8f52f2fe844
Date: Sat Feb 6 14:21:59 2016 +0100
U2: appended once file.txt

commit 50ab9d12ec08854737a8d66c67647acc4af7e7b1
Date: Sat Feb 6 14:21:02 2016 +0100
U1: created new file.txt

git status
On branch master
Your branch is ahead of ‘origin/master’ by 1 commit.
(use “git push” to publish your local commits)
nothing to commit, working directory clean

git push origin master

git log
commit 36876c0914fc56eeb86aeb5fb274f02323099b32
Date: Sat Feb 6 14:21:05 2016 +0100
U1: appended once file.txt
commit d7c88b0c87aa9f0993924a5fd0ded8f52f2fe844
Date: Sat Feb 6 14:21:59 2016 +0100
U2: appended once file.txt
commit 50ab9d12ec08854737a8d66c67647acc4af7e7b1
Date: Sat Feb 6 14:21:02 2016 +0100
U1: created new file.txt

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s