Reputation:
I have a git repository with two branches: master
and live
. I work on master
. Once I deem my changes ready for production, I merge them into live
, which is checked out in the production system. I work on the project alone.
With this setup, live
always used to simply be a few commits behind master
. So when I did a git merge master
on live
, the merge would be performed via fast-forward
.
As of recently, doing git merge master
while on live
results in a merge performed by the recursive
strategy. I don't know if the reason for this is that I once accidentally committed a change first on live
, and only afterwards merged it onto master
.
git diff master live
yields no output, ie. the two branches have the same file contents.
What can I do to get my git repository into a "clean" state so it again uses the fast-forward
strategy by default?
Upvotes: 3
Views: 7532
Reputation:
I think the problem was caused because:
A
) on live
instead of master
.B
say) on master
.live
onto master
.B
onto live
, so I merged master
onto live
.I think this created a "crossing" of commit paths that makes it impossible for git merge
to fast-forward.
The solution was to first ensure that the two branches really did have the same contents:
git diff master..live
git cherry -v master live
git cherry -v live master
all yielded no result. Then I changed live
to point at exactly the same commit as master:
git branch -f live ae5e70... # Hash of the commit pointed to by master
git push --force origin live:live
Now I can fast-forward again. Note that this can be dangerous and should probably not be done when the repository is shared.
Upvotes: 2