Git:合并一个分支,但没有一些我只需要修改的文件? [英] Git: Merge a branch but without some of the files I only need modified locally?

查看:131
本文介绍了Git:合并一个分支,但没有一些我只需要修改的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种特殊情况,这很简单,但我没有在这里看到类似的问题。



我在我的工作中从远程仓库复制自己的分支,并将我自己的任务添加到 Capistrano Capfile 。这些任务只会帮助我将应用程序部署到我自己的私人服务器,因此,当我们的分支与 origin master 合并时,我不希望Capfile中的更改被推送到 remote master repo ,因为很显然,这个文件应该在那里保持完整无需我的个人修改。



处理这种情况的最佳做法是什么?

预先致谢!

PS。我想我正在寻找的是一种专门为分支 Git忽略文件的方法。我会建议分支一个现在的分支(让我们命名它 Local > / code>)off from your current branch(让它命名为原始)。

c $ c>原始,您将还原对capfile所做的更改。在本地中,您将照常继续处理数据。在重新合并到远程服务器之前,您将 Local 合并到原始,然后只需按原始。如果不进一步更改本地Capfile,则应该没问题,否则必须(再次)还原这些更改(尽管这会导致合并冲突,因此您可以直接在合并中处理它)。


I have this particular scenario, which is simple really, but I don't see (so far) a similar question here.

I'm working in my own branch copied from a remote repo, And I have added my own tasks to a Capistrano Capfile. These tasks will only help Me deploy the app to my own private server, Therefore when it's time to Merge my branch with origin master, I don't want the changes in the Capfile to be pushed to the remote master repo, because, obviously, this file should remain intact over there without my personal alterations.

What's the best practice to deal with this situation?

Thanks in advance!

PS. I guess that what I'm looking for, is a way to 'Git Ignore' files exclusively for a branch. To over simplify things.

解决方案

I would suggest to branch a now branch (lets name it Local) off from your current branch (lets name it Original).

In Original, you revert the changes you made to the capfile. In Local, you continue working on your data as usual. Before it comes to remerge into the remote, you merge Local to Original and just push Original. If you do not change the local Capfile further, it should be fine, otherwise you have to (again) revert those changes (although that should result in a merge conflict anyways, so you can handle it in the merge directly).

这篇关于Git:合并一个分支,但没有一些我只需要修改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆