git 中心分支
我正在使用 github,我有以下问题,我有一个 master 分支,并且我通过执行
Git branch {branchname"
Git checkout {branchname}.
“现在我需要编辑一些设置文件”从 master 分支创建了一个新分支,我应该从我的新分支还是 Master 编辑此文件吗?如果我从新分支编辑它,那么每次我为不同的项目创建一个新分支时,我应该修改这个设置文件......但同时如果我通过在主分支上编辑它,那么当我合并/稍后更新主分支,然后我就会放弃更改。有人可以澄清处理这个问题的最佳方法吗?如果我必须从主分支执行此操作,那么我如何隐藏它,因为我从不从主分支推送任何内容。
I am using github and I have the following question, I have a master branch and I created a new branch out of master by doing
Git branch {branchname"
Git checkout {branchname}.
Now I need to edit some settings file , should I edit this file from my new branch or the Master? If I edit it from the new branch, then each time I create a new branch for different projects, then I should be modifying this settings file…but at the same time if I edit it by being on master branch, then when I merge/update master branch later, then I would loose the changes. Can someone please clarify the best way to handle this? If I have to do it from Master, then how I can stash it as I never push anything from master branch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于你想要什么。如果您希望新设置在任何地方都可用,则需要修改 master 中的文件,将其签入,然后对任何现有分支进行变基以获取设置。
如果您只想在另一个分支中进行更改,请在那里进行更改。如果您将另一个分支合并回 master,那么 master 将拥有它们。
it depends what you want. If you want the new settings to be available everywhere, you need to modify the file in master, check it in, then rebase any existing branches to get the settings.
If you only want the changes in the other branch, make them there. If you ever merge the other branch back into master, then master will then have them.