仅从特定文件夹进行 Git 合并
我已经为客户 X 创建了一个 Rails 网站。我现在有一个客户 Y,他想要一个与客户 X 执行完全相同的操作但具有不同外观的网站。
我从 clientXcode 创建了一个 git 分支,并将其命名为 clientYcode。然后我对视图进行了所有更改,使其看起来不同,拉拉,同一个网站,但皮肤不同。
现在,我对 git 不明白的地方是:我对 clientXcode 的视图、模型和控制器做了很多更改;现在我想将这些更改合并到 clientYcode 中,不包括任何视图更改。由于视图、模型和控制器在 Rails 中都有自己的文件夹,因此我希望能够执行以下操作:
git merge client_x_code 'app/controllers/*', 'app/models/*'
问题 1:使用 git 可以实现类似的操作吗?如果是这样,我该怎么做?
问题 2:分支是复制我的项目的最佳解决方案吗?
I've created a rails website for client X. I now have a client, Y, who wants a website that does the exact same thing as client X, but with a different skin.
I made a git branch from clientXcode and called it clientYcode. I then did all the changes to the views to make it look different, and lala, the same website with a different skin.
Now here's what I don't understand about git: I've made many changes to clientXcode in the views, models, and controllers; and now I want to merge those changes into clientYcode, excluding any view changes. Since views, models, and controllers each have their own folder in rails I was hoping to be able to do something like:
git merge client_x_code 'app/controllers/*', 'app/models/*'
QUESTION 1: Is something like that possible with git? If so, how would I do it?
QUESTION 2: Was branching the best solution to make a copy of my project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我找到了解决我的问题的最简单的解决方案......
这就是我想要的!
Well I found the easiest solution to my problem...
And that does what I want!
最简单的做法是合并除要保留的目录内容之外的所有内容。
您可以通过在该目录中添加合并驱动程序来做到这一点,如 如何告诉 git 始终选择本地版本来进行特定文件上的冲突合并? 问题详细信息。
有了合并驱动程序,分支在这种情况下是一个很好的解决方案。
提炼:
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: