How to merge specific files from Git branches

后端 未结 11 1867
长发绾君心
长发绾君心 2020-11-30 16:23

I have 2 git branches branch1 and branch2 and I want to merge file.py in branch2 into file.py in branch1 and only that file.

In essence I just want to work on the fi

11条回答
  •  鱼传尺愫
    2020-11-30 16:56

    What I've done is a bit manual, but I:

    1. Merged the branches normally; Reverted the merge with revert;
    2. Checked out all my files to HEAD~1, that is, their state in the merge commit;
    3. Rebased my commits to hide this hackery from the commit history.

    Ugly? Yes. Easy to remember? Also yes.

提交回复
热议问题