Skip to content

Instantly share code, notes, and snippets.

@alainravet
Created July 29, 2016 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alainravet/60ae6c4ab1e88291ae0b2d7df6ec11ab to your computer and use it in GitHub Desktop.
Save alainravet/60ae6c4ab1e88291ae0b2d7df6ec11ab to your computer and use it in GitHub Desktop.
git merge vs rebase+merge sample generation
slip() {
sleep 1
}
rm -rf contents
mkdir contents
cd contents
git init
touch m0 ; git add . ; git commit -m "M0"
slip ; git co -b br_A
slip ; git co br_A ; touch br_A ; git add . ; git commit -m "A-1"
slip ; git co master ; touch m1 ; git add . ; git commit -m "M1"
slip ; git co -b br_B
slip ; git co br_B ; touch br_B ; git add . ; git commit -m "B-1"
slip ; git co master ; touch m2 ; git add . ; git commit -m "M2"
slip ; git co -b br_C
slip ; git co br_C ; touch br_C ; git add . ; git commit -m "C-1"
slip ; git co master ; touch m2 ; git add . ; git commit -m "M2"
slip ; git co master ; touch m3 ; git add . ; git commit -m "M3"
slip ; git co br_A ; touch br_A2 ; git add . ; git commit -m "A-2"
slip ; git co br_B ; touch br_B2 ; git add . ; git commit -m "B-2"
slip ; git co br_C ; touch br_C2 ; git add . ; git commit -m "C-2"
slip ; git co br_C ; touch br_C3 ; git add . ; git commit -m "C-3"
slip ; git co br_B ; touch br_B3 ; git add . ; git commit -m "B-3"
slip ; git co br_A ; touch br_A3 ; git add . ; git commit -m "A-3"
git co master
# BEFORE
slip ; git co master ; touch m4 ; git add . ; git commit -m "M4"
# MERGE
# slip ; git merge --no-ff br_B --no-edit
# slip ; git co master ; touch m4 ; git add . ; git commit -m "M4"
# slip ; git merge --no-ff br_C --no-edit
# slip ; git merge --no-ff br_A --no-edit
slip ; git merge br_B --no-edit
slip ; git co master ; touch m4 ; git add . ; git commit -m "M4"
slip ; git merge br_C --no-edit
slip ; git merge br_A --no-edit
# REBASE and MERGE
# slip ; git co br_B ; git rebase master ; git co master
# slip ; git merge --no-ff br_B --no-edit
# slip ; git co master ; touch m4 ; git add . ; git commit -m "M4"
# slip ; git co br_C ; git rebase master ; git co master
# slip ; git merge --no-ff br_C --no-edit
# slip ; git co br_A ; git rebase master ; git co master
# slip ; git merge --no-ff br_A --no-edit
# git hist
cd ..
# tree
@alainravet
Copy link
Author

git-before-merge

git-simple-merge

git-after-rebase-plus-merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment