gitmergeunstage

Remove unstaged files from merge


i have two branches, one more updated than other one and I want to merge into the outdated one the updated but only the commits that don't cause conflicts. When I do the merge and try to checkout the unstaged files it says 'warning: path "my file" is unmerged' and i want to merge anyways, how can i do that?


Solution

  • Let's call your branches outdated and updated. I'm assuming you want to do the merge of updated into outdated without merging the conflicted files but somehow keeping your updated branch's version of them. So:

    1. Get on outdated. Attempt the merge of updated.

    2. Git emits a list of conflicting files.

    3. Write down their pathnames.

    4. Abort the merge.

    5. Get back on updated. Copy the conflicting files to a place of greater safety (outside this worktree).

    6. Checkout, from outdated, the conflicting files, thus overwriting the conflicting files in updated with versions of those files that do not conflict because they are identical.

    7. Get back on outdated and do the merge.

    8. Get back on updated and copy the conflicting files back into the worktree.