2
anolis
5y

Git Question:

Semiunusual state here. Have a branch I'm trying to merge into develop and there are a LOT of merge conflicts, some head way has been made in this merge branch..

HOWEVER

I'm wondering is there a way to "suspend" the branch/merge progress and go back to develop?

Comments
  • 0
    What I tend to do:

    1. copy off all the commit hashes you've made on your branch you want to merge (git log, or tig)

    2. pull down the latest master

    3. git cherry-pick all your commits in order. git rebase -i <hash before your first cherry-pick on master>

    4. If you have multiple commits that should just be one, squash them into relevant names and features

    5. Push your new branch and submit a merge request.

    6. Get it merged in.

    7. Delete the old working branch
  • 1
    I'm curious, why not rebase your working branch and keep the conflicts there in the first place?

    Also, shouldn't you be already on develop, if you're merging a feature?
  • 0
    Well, the way it works here is to merge develop into the feature then pr the branch
  • 2
    Git merge --abort

    Git checkout -b new-branch for squash merge
    Git reset --soft {commit hash of the point you deviated from Target branch}
    Git commit -m {message}
    Git rebase {target branch}

    ^single commit merge, much easier

    And don't use non-fast forward merges, or any mechanism that produces a merge commit; they render git bisect and git revert useless
  • 1
    Thank you for this advice, will be useful in the future,

    Was just wondering if it was possible to leave a merge in the middle of fixing conflicts and navigate back to develop
  • 0
    @anolis
    Git merge --abort 👍
  • 0
    @SortOfTested that undos any of the merge progress that has been made afaik
  • 1
    @anolis
    Believe it or not, there's a method for that:

    Git rerere (not kidding)
    https://git-scm.com/docs/git-rerere

    The theory is that rerere will allow you record your merges as you go, then apply them all at once in the final merge.

    #GitFu
  • 0
    Great information here guys, thanks a lot, going to try rerere tomorrow :)
Add Comment