MarkE MarkE - 1 year ago 105
Git Question

Filtered all commits in my local git repository, best way to update remote?

I ran a filter that converted all my files in all revisions to Unix line-endings. I now see that git states all revisions of my local and remote have diverged. Git status tells me to do a pull and merge. What is the best way to replace all remote commits with my local commits?

Answer Source

You will need to do a force push. The "best" way these days is to use --force-with-lease to make sure that no one else has updated the remote repository since you last obtained everything from it. If it's a private (or mostly private) repository, of course, no one else should be updating it, and you can just use a regular force-push.

(The drawback to force-push is that, if it succeeds, it makes the other Git overwrite its branch-names with the new commit IDs you give it. This loses all the old commits ... so anyone who was using and depending on them, now has to take care of this in their clone of that remote. In this case, you really do want to lose all those old commits, so it's a question of whether anyone else is using them, and if so, whether you care about those other people.)

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