Git merge from a specific folder only

为君一笑 提交于 2019-11-30 10:31:21

Well I found the easiest solution to my problem...

git checkout clientYcode
git checkout clientXcode "app/controllers/"
git checkout clientXcode "app/models/"

And that does what I want!

VonC

The simplest course of action is to merge everything, except the content of the directory you want to keep.
You can do that by adding a merge driver in that directory, as the How do I tell git to always select my local version for conflicted merges on a specific file? question details.

With that merge driver in place, Branching is a good solution in this case.


Extract:

We have a .gitattributes file defined in the dirWithCopyMerge directory (defined only in the branch where the merge will occurs: myBranch), and we have a .git\config file which now contains a merge driver.

[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!