如何避免将“分支特定"文件推送到master分支? [英] How to avoid pushing 'branch-specific' files to master branch?

查看:159
本文介绍了如何避免将“分支特定"文件推送到master分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这个问题很难理解,所以这是一个例子:

I guess this question is hard to understand, so here's an example:

假设我有一个项目,并且我正在使用Git,并且在Master分支上有文件A,B,C ...然后创建一个Test分支并创建文件D并用一些行修改文件A.之后,我推送到[Bitbucket,Github],所以我有一个包含3个文件的Master分支和一个包含4个文件的Test分支.

Assume I have a Project and I'm using Git, with files A,B,C on Master branch... then I create a Test branch and create file D and modify file A with some lines. after this I push to [Bitbucket, Github] and so I have a Master Branch With 3 Files and a Test Branch with 4 Files.

我回到Master分支并开始其他工作,有些不同,当我尝试提交时,它说我应该添加D文件,它将提交对文件A的更改.

I go back to Master branch and start working on something else, something different, and when I try to commit it says that I should Add D file and it's going to commit the changes on file A.

我的问题是,如何避免在Master Branch上进行此更改? 以及如何在我的本地文件夹中处理此问题?如果我希望它看起来像"Master"分支,我应该删除文件夹并克隆存储库,删除文件D并由我自己还原对文件A的更改,还是理想的方式?

My question is, how can I avoid this changes on Master Branch? and how should I deal with this on my local folder? if I want it to look just like 'Master' branch should I delete the folder and clone the repo, delete the file D and revert changes on file A by myself, or what should be the ideal way to do it?

推荐答案

您必须提供确切的命令顺序才能获得正确的答案.
但是从您写的内容来看,我猜您没有将这些更改提交到Test分支,而只是将它们添加到索引中,然后进行了推送或类似的操作?
因为如果您先提交到Test Branch然后签出master,则所做的更改和新文件将不在工作树中.

You would have to provide your exact sequence of commands to get a correct answer.
But from what you have written I'd guess that you did not commit those changes to Test branch, but maybe only added them to the index and then did a push or something like that?
Because if you would have committed to Test Branch and then checked out master, your changes and your new file would not be in the working tree.

这篇关于如何避免将“分支特定"文件推送到master分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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