隐藏但仍使用GIT保存分支? [英] Hide but still save a branch with GIT?
问题描述
我有很多分支,使用起来有些混乱.有时我不想完全删除该分支,但是我将暂时不使用它.在这种情况下,Ive采用了以_前缀分支的约定.
I have a large number of branches which is getting a bit confusing to work with. Sometimes I dont want to delete the branch completely but I wont be working on it for a while. Ive adopted a convention of prefixing branches with _ when that is the case.
所以,如果我从以下内容开始:
So if i start out with:
branch1
branch2
branch3
当我用完branch1但想要保存它的备份时,以防万一,然后生病重命名为:
When Im done with branch1 but want to save a backup of it just incase then ill rename to:
_branch1
branch2
branch3
这在一段时间内效果很好,但是我的工作区现在变得有些混乱.无论如何,将分支保存在某个地方以便可以对其进行恢复,但使其不在常规工作空间中(就像已将其删除一样)吗?
This worked well for a while but my workspace is getting a bit cluttered now. Is there anyway of saving a branch somewhere so it can be recovered, but so that its not in the normal workspace (as if its been deleted)?
推荐答案
将旧分支保留在单独的存储库中.
Preserve your old branches in a separate repository.
也就是说,如果您使用的是 $ HOME/myproject
,请克隆您的存储库:
That is, if you're working in $HOME/myproject
, clone your repository:
cd $HOME
git clone myproject myproject_archive
现在,将 _archive
存储库设置为主数据库上的远程数据库储存库:
Now, set up the _archive
repository as a remote on your primary
repository:
cd myproject
git remote add archive ../myproject_archive
现在删除 myproject
中的所有旧"分支:
Now delete all the "old" branches in myproject
:
git branch -D _branch1
etc...
您都准备好了!您的分支机构继续存在于 myproject_archive
存储库,现在您可以轻松地归档新的分支机构:
And you're all set! Your branches continue to exist in the
myproject_archive
repository, and you can now trivially archive new
branches:
git branch -m branch2 _branch2
git push _branch2 archive
git branch -D branch2
这篇关于隐藏但仍使用GIT保存分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!