我只是很好奇,因为我注意到有些存储库的分支设置如下:
git branch -a
master
remotes/origin/branch1
remotes/origin/branch2/lala
remotes/origin/branch2/yay
remotes/origin/branch3
remotes/origin/branch4
我只是好奇他们如何在branch2下进行分支lala
和yay
;或者那不是分支?
有什么见解?
答案 0 :(得分:7)
branch2/lala
和branch2/yay
分支并非真正位于名为branch2
的分支之下。每个都只是一个普通的分支,其名称恰好包含/
。
:; cd /tmp
:; mkdir gittest
:; cd gittest
:; mkdir origin
:; cd origin
:; git init
Initialized empty Git repository in /private/tmp/gittest/origin/.git/
:; touch somefile
:; git add somefile
:; git commit -m 'initial commit'
[master (root-commit) 4d62ed7] initial commit
0 files changed
create mode 100644 somefile
:; git branch branch1
:; git branch branch2/lala
:; git branch branch2/yay
:; git branch branch3
:; git branch branch4
:; git branch -a
branch1
branch2/lala
branch2/yay
branch3
branch4
* master
:; cd ..
:; git clone origin local
Cloning into 'local'...
done.
:; cd local
:; git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/branch1
remotes/origin/branch2/lala
remotes/origin/branch2/yay
remotes/origin/branch3
remotes/origin/branch4
remotes/origin/master