I'm working on a lenghty merging process with several conflicts.
What can I do to save the intermediate state, in order to periodically keep backups in case disaster strikes?
You can use the git reset --merge command. You can also use the git merge --abort command. As always, make sure you have no uncommitted changes before you start a merge.
You can undo a Git merge using the git reset –merge command. This command changes all files that are different between your current repository and a particular commit. There is no “git undo merge” command but the git reset command works well to undo a merge.
You can commit your work in progress and push it on a server in a temporary branch. But to do that, you'll have to commit file with conflict markers (git add . ; git commit
). And I'll advice you not to do it, as it is too easy to miss one of the place in conflict when you come back to the merge. You can also try to squash your merge in progress (git squash save
), but I don't know if it is possible to push a squash reference on a server.
Another alternative would be to try to split your complex merge in smaller blocks, and to push each intermediate merge.
For example, if you have the following history:
*---*---*---*---*---*---*---*---*---A
\
\--*---0---1---2---3---4---5---B
And try to merge B into A, you can accomplish the same thing by first merging 0, then 1, then 2, then 3, ... then finally B (0, 1, 2, ... may not be successive commit, but some important milestones in the B branch).
This is the strategy we are using when doing complex merge. The merged branch may not be in a workable state during those merge, so don't push directly to A, but to another branch (A-B-merge), then once the merge is finished, push everything to A.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With