Skip to content

Instantly share code, notes, and snippets.

@mrtns
Last active June 7, 2018 14:24
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 mrtns/b8ccfda81e510c81310e026cb53ff168 to your computer and use it in GitHub Desktop.
Save mrtns/b8ccfda81e510c81310e026cb53ff168 to your computer and use it in GitHub Desktop.
Git rebase, skip merge-commits

Via https://stackoverflow.com/questions/25886147/git-rebase-skip-merge-commits

git init

touch C1
git add -A
git commit -am "C1"

touch C2
git add -A
git commit -am "C2"

touch C3
git add -A
git commit -am "C3"

git checkout f8e610d
git checkout -b feature

touch F1
git add -A
git commit -am "F1"

git merge master
touch F2
git add -A
git commit -am "F2"
git log --all --graph --decorate --oneline
* 19767e0 (HEAD -> feature) F2
*   11a9be2 Merge branch 'master' into feature
|\  
| * 66860a0 (master) C3
| * 723a8d1 C2
* | f7ed465 F1
|/  
* f8e610d C1
git rebase --onto master f8e610d feature
First, rewinding head to replay your work on top of it...
Applying: C2
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: C3
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: F1
Applying: F2
git log --all --graph --decorate --oneline 
* d8b01d8 (HEAD -> feature) F2
* 4cee191 F1
* 66860a0 (master) C3
* 723a8d1 C2
* f8e610d C1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment