简体   繁体   English

我可以签出git分支而不从本地文件中删除其他孤立分支吗?

[英]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的不同分支中( masterdemo )。 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.

相关问题 Git,从另外两个分支(B和C)创建本地分支(A),然后从A到B合并而不包含C文件 - Git, create local branch (A) from two other branches (B and C) and then merge from A to B without C files 我怎么知道我的本地分支是从哪个git远程分支签出的? - How can I know from which git remote branch my local branch was checked out? 如何在GIT中消灭我当地的分支机构? - How can I wipe out my local branch in GIT? 我一直在从旧分支创建新的 Git 分支,而没有签出到主分支 - I have been creating new Git branches from older branch without checking out to the master 合并 Master 分支、修复冲突、从合并中删除其他文件后,GIT 将我的功能分支中的文件视为最新文件 - After merging Master branch, fixing conflicts, removing other files from the merge, GIT is treating files in my feature branch as latest git,本地分支上的更改会影响其他本地分支吗? - git, change on local branch affects other local branches? 如何合并git分支以使主题提交成为孤立的? - How can I merge a git branch so that topic commits are orphaned? Git:如何检出而不从当前分支中删除独占文件 - Git: How to checkout without removing exclusive files from current branch git 在不覆盖本地分支上的文件的情况下拉主 - git pull master without overwriting my files on the local branch 如何使用git将另一个分支中的文件签出到当前分支的新文件中? - How can I check out a file from another branch into a new file in the current branch with git?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM