Skip to content

Instantly share code, notes, and snippets.

@saml
Created July 17, 2013 10:26
Show Gist options
  • Select an option

  • Save saml/6019427 to your computer and use it in GitHub Desktop.

Select an option

Save saml/6019427 to your computer and use it in GitHub Desktop.
*   35f15b3 (HEAD, master) Merge f1
|\  
| * 3a97d51 f1.b
| * 8108b2e f1.a
|/  
| * db73034 (f2) f2.b
| * 0d4b922 f2.a
|/  
* 7ae194b start

How do I rebase f2 to master so that when I merge f2, it'll look like:

* abc123 (HEAD, master) Merge f2
|\
| * db73034 f2.b
| * 0d4b922 f2.a
|/
*   35f15b3 Merge f1
|\  
| * 3a97d51 f1.b
| * 8108b2e f1.a
|/  
* 7ae194b start

If I do git rebase master or git rebase --onto master master, I lose work of f2 branch:

*   4243354 (HEAD, master, f2) Merge f1
|\  
| * db6b06b f1.b
| * 97d4e19 f1.a
|/  
* cc2f6c1 start
@saml

saml commented Jul 17, 2013

Copy link
Copy Markdown
Author
git commit --allow-empty -m start

# start f1
git checkout -b f1 master
git commit --allow-empty -m f1.a
git commit --allow-empty -m f1.b

# start f2
git checkout -b f2 master
git commit --allow-empty -m f2.a
git commit --allow-empty -m f2.b

# end f1
git checkout f1
git rebase master
git checkout master
git merge --no-ff -m 'Merge f1' f1 
git branch -d f1

# end f2
git checkout f2
git rebase master
git checkout master
git merge --no-ff -m 'Merge f2' f2
git branch -d f

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