Reputation: 4098
Lets say I make 30 commits in branch cool-feature
that I pulled from master.
I merge cool-feature
into master
using the merge squash function in github. The 30 commits turn into 1.
In my eagerness, I then start to write another feature onto cool-feature
because I forgot to make a new feature branch off master
because I'm an idiot.
If no other commits are made to master
, and I merge master
into cool-feature
again, I catch all sorts of merge conflict hell, even though I technically already have master
in my branch: its just that I have a different history in cool-feature
because of the commit squash. I wouldnt get the grief if I hadnt squashed the commits.
Im going to keep squashing on my merges to master
, is there a clean way to handle the above?
Upvotes: 1
Views: 156
Reputation: 4098
I solved this by git stash
ing my changes, making a new branch off develop
, and git stash apply
ing.
Upvotes: 0
Reputation: 36739
You have the following situation:
A-B-C-S # master
\
D-E-F-X-Y-Z # cool-feature
Where D,E,F
were commits that got squashed into S
and subsequently merged into master
.
X,Y,Z
are the overeager commits to cool-feature
after it has been squashed and merged.
What you can do is run
git rebase -i S
where S
is the SHA1 of the squashed commit. You will be shown a text file
pick D commit message
pick E commit message
pick F commit message
pick X commit message
pick Y commit message
pick Z commit message
If you now simply drop all lines corresponding to commits contained in S
(the first three, D,E,F
in this case) you will rebase the rest of the branch on top of S
:
A-B-C-S # master
\
X-Y-Z # new cool-feature
After doing that you can merge master into cool-feature
or vice versa.
Upvotes: 1