ksp0422 ksp0422 - 1 year ago 74
Git Question

git rewrite history from fast-forward to no-fast-forward

so I've been working on an Android project for a while doing backend & native client development. The project has made some progress from then and I am the only the project committer, so I basically fast-forward-merged everything I added or fixed. Now my company wants a new Android developer and pull me to the back end team. I want to rewrite my android repo history and show what features have been added / fixed / released and all that. So I want my fast-forwarded linear commit history to be re written in a form of non-fast-forwarded type. Is this possibe?

Answer Source

By looking into the output of git reflog, or via grep:

git reflog --date=iso | grep -i Fast-forward

One can find the 'merge' commits resulted from fast forward:

b69e480 HEAD@{422}: merge b69e480: Fast-forward
38e2ace HEAD@{438}: merge 38e2ace: Fast-forward

Then it should be possible to restore those branches, and re-merge them with --no-ff flag, by first re-winding HEAD back to the proper start point.

There's a related blog, demonstrating how to recover a bad merge, which used the same approach, and it might be a good example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download