1

Situation: I have a topic branch which has been squashed into master. I then added some additional commits to the topic branch and want to merge these additional commits into master. Is there any way to do this?

Graph:

master A - B - F

             \

topic          C - D - E (squashed into F) - G - H

Question -- How to get G and H onto F?

My takeaway from Rebasing after squash merge? has been to update the topic branch parent after a squash so as to avoid this situation all together. My solution for now to unstick myself has just been to create a patch containing my new changes and apply this patch to master, but I'm losing commit history doing this, so it's not ideal.

Thanks!

Community
  • 1
  • 1
Puhlze
  • 2,634
  • 18
  • 16
  • I haven't checked, but have you tried simply "git merge --squash" again? As far as I remember, squash merge is content based, so it should work. Test it! – Adam Adamaszek Jan 25 '13 at 16:43
  • This is causing merge conflicts between the previously squashed commit and the new changes, so I dont think this works. Thanks for the suggestion. – Puhlze Jan 25 '13 at 16:56
  • @Jeranimot Have you seen http://stackoverflow.com/questions/14343711/git-ignores-deleted-file-on-merge ? – Borealid Jan 25 '13 at 17:12
  • @Borealid Thanks -- hadn't seen that. Makes sense. – Puhlze Jan 25 '13 at 18:16

2 Answers2

2

if I understand you correctly the way of doing this is cherry-picking: https://ariejan.net/2010/06/10/cherry-picking-specific-commits-from-another-branch

Stephan
  • 1,639
  • 3
  • 15
  • 26
  • Wasn't aware of cherry picking -- this certainly is preferable to using patches. I think this is the best that can be done here as squashing seems to cause merge troubles with future branch merges, so I'll just be sure to reset the branch parent after a squash merge. Thanks! – Puhlze Jan 25 '13 at 16:59
-1

merge again.

squash or no-squash both will work. no squash will create merge commit.

forvaidya
  • 3,041
  • 3
  • 26
  • 33
  • 1
    No! If you do another `merge --squash` it'll include the stuff that was part of the first `merge --squash`. You don't want to do this. See http://stackoverflow.com/questions/14343711/git-ignores-deleted-file-on-merge . – Borealid Jan 25 '13 at 17:13