How to merge specific files from Git branches

后端 未结 11 1873
长发绾君心
长发绾君心 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:47

    I am in same situation, I want to merge a file from a branch which has many commits on it on 2 branch. I tried many ways above and other I found on the internet and all failed (because commit history is complex) so I decide to do my way (the crazy way).

    git merge 
    cp file-to-merge file-to-merge.example
    git reset --hard HEAD (or HEAD^1 if no conflicts happen)
    cp file-to-merge.example file-to-merge
    

提交回复
热议问题