2

我只是好奇,因为我注意到一些存储库的分支设置如下:

git branch -a

master
remotes/origin/branch1
remotes/origin/branch2/lala
remotes/origin/branch2/yay
remotes/origin/branch3
remotes/origin/branch4

我只是好奇他们是如何在分支lala和分支yay2下做的;或者那不是一个分支?

有什么见解吗?

4

1 回答 1

7

branch2/lalaandbranch2/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
于 2012-11-13T22:15:40.783 回答