简体   繁体   English

在分支之间移动时出现文件冲突问题

[英]File conflicts issue when moving between branches

I have a SourceTree issue with moving between branches due to file conflicts. 由于文件冲突,我在分支之间移动时遇到SourceTree问题。 Basically I am working in a small team and we each have our own Web.config files which have distinct properties to our individual machines (like directory paths eg. C:/Mark/Documents/Project/) Each time I move between branches I have conflicts because of these files. 基本上,我是在一个小型团队中工作,我们每个人都有自己的Web.config文件,这些文件对我们的每台机器都有不同的属性(例如目录路径,例如C:/ Mark / Documents / Project /),每次我在分支之间移动时,这些文件导致冲突。 I do not want to commit these files because it means when someone else moves to that branch they will need to commit their Web.config changes - which means when I return to it I will need to commit the files again, and so on. 我不想提交这些文件,因为这意味着当其他人移至该分支时,他们将需要提交其Web.config更改-这意味着当我返回该分支时,我将需要再次提交文件,依此类推。 Is there some Git tool or procedure I can use to get around this issue we are having. 有没有一些我可以用来解决这个问题的Git工具或过程。

Thanks in advance 提前致谢

If I understand you correctly all you need to do is add Web.config to your .gitignore . 如果我对您的理解正确,那么您只需将Web.config添加到.gitignore

That will prevent git from tracking changes to the file. 这将防止git跟踪对文件的更改。 Each user can do whatever they like to it without creating conflicts. 每个用户都可以做自己喜欢的事情而不会产生冲突。

I guess that file is modified by someone or by something, but not committed before you switch to another branch. 我猜该文件已被某人或某物修改,但在切换到另一个分支之前未提交。 Make the work tree clean before switching. 切换之前,使工作树清洁。 Discard the changes of that file if they are not needed via git checkout -- <path_of_that_file> . 如果不需要通过git checkout -- <path_of_that_file>进行更改,则放弃该文件的更改。 Commit them if they are needed. 如果需要,请提交它们。 Run git status to see if the work tree is clean. 运行git status以查看工作树是否干净。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM