[英]Can I check out a git branch without removing other orphaned branches from my local files?
I have two related projects that are in separate branches of the same git repo ( master
and demo
). 我有两个相关的项目,它们在同一个git repo的不同分支中(
master
和demo
)。 When I check out the master
branch, it removes the files in my demo folder from my local hard drive, and vice versa with the demo
branch checked out. 当我检查出
master
分支,它从我的本地硬盘驱动器中删除我的演示文件夹中的文件,并与反之亦然demo
分公司签出。 Is it possible to avoid this behavior? 是否可以避免这种行为?
您可以在合并两个分支的地方创建第三个分支。
For any local GIT repository, there can be up to one working directory at a given time. 对于任何本地GIT存储库,在给定时间最多可以有一个工作目录。 For that reason, the files in the 'folder' (working dir) are replaced when you switch branches.
因此,切换分支时将替换“文件夹”(工作目录)中的文件。 A possible workaround i'm sometimes using (assuming you have a remote repository from which you've cloned the local one) is create another local repository pointing to the same remote repository (= create another folder in your computer and clone the same repository).
我有时使用的一种可能的解决方法(假设您有一个从中克隆了本地存储库的远程存储库)是创建另一个指向相同远程存储库的本地存储库(=在计算机中创建另一个文件夹并克隆相同的存储库) 。 Now, in one repo checkout master, in the second one checkout demo, and you can work on both branches in parallel.
现在,在一个仓库中,在第二个演示中,您可以在两个分支上并行工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.