How to avoid pushing 'branch-specific' files to master branch?

*爱你&永不变心* 提交于 2019-12-25 01:15:29

问题


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

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.

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/36925672/how-to-avoid-pushing-branch-specific-files-to-master-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!