简体   繁体   English

在SVN和Git中的分支之间切换

[英]Switching between Branches in SVN and Git

In SVN (or Git), suppose you are in a working copy directory which has been created by checking out branch A. Now, I need to work and commit to branch B. 在SVN(或Git)中,假设您处于通过签出分支A创建的工作副本目录中。现在,我需要工作并提交分支B.

In SVN, I can use the svn switch B and in Git, I can use git checkout B in order to switch to the branch B. 在SVN中,我可以使用svn switch B ,在Git中,我可以使用git checkout B来切换到分支B.

However, I always have fear of this switching operation; 但是,我总是担心这种切换操作; so, I end up creating a new working copy and when I need to work on many branches, I end up with many obsolete working directories. 所以,我最终创建了一个新的工作副本,当我需要在许多分支上工作时,我最终得到了许多过时的工作目录。

My question is if the switching the same working copy between different branches is totally safe or not. 我的问题是,在不同分支之间切换相同的工作副本是否完全安全。 Do SVN or Git keep any of the files which belong to the other branch, or they really clean up and switch to the new branch? SVN或Git是否保留属于其他分支的任何文件,或者它们是否真的清理并切换到新分支?

A switch between branches is the safe operation. 分支之间的切换是安全的操作。 I see only one concern: if you have a lot of modified files in your working copy. 我只看到一个问题:如果你的工作副本中有很多修改过的文件。 You may be require to perform a merge or your modified files will be removed. 您可能需要执行合并,否则您的修改后的文件将被删除。 So, if you have a lot of modified files it is better to checkout a new brunch in a new folder. 因此,如果你有很多修改过的文件,最好在新文件夹中查看新的早午餐。

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

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