Skip to content

Instantly share code, notes, and snippets.

@iliakan
Created April 9, 2018 13:35
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 iliakan/fafc4d0005c9f391b9717c9d8a64831b to your computer and use it in GitHub Desktop.
Save iliakan/fafc4d0005c9f391b9717c9d8a64831b to your computer and use it in GitHub Desktop.
#!/bin/bash
# DEMO: git rebase SKIPS merge commit, COPIES whole all merged branch
# DEMO: git rebase -p copies merge commit D', but IGNORES changes in it
cd ~/project
rm -rf .git
rm my.txt x.txt
git init
printf "A\n\n" > my.txt
git add my.txt
git commit -m A
git tag A
git checkout -b idea
printf "X\n\n" > x.txt
git add x.txt
git commit -m X
git tag X
printf "Y\n\n" > x.txt
git add x.txt
git commit -m Y
git tag Y
git checkout master
printf "B\n\n" >> my.txt
git commit -am B
git tag B
git checkout -b feature
gsed -i 's/B/C/g' my.txt
git commit -am C
git tag C
gsed -i 's/C/D/g' my.txt
git merge -m D idea --no-commit
printf "MERGED\n\n" > x.txt
git add x.txt
git commit --no-edit
git tag D
gsed -i 's/D/E/g' my.txt
git commit -am E
git tag E
git checkout master
printf "F\n\n" >> my.txt
git commit -am F
git tag F
printf "G\n\n" >> my.txt
git commit -am G
git tag G
git checkout feature
git branch feature-old feature
#git rebase master -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment