“git clone -b name url”与“git clone url --branch name”是否相同?

时间:2014-07-14 20:34:47

标签: git git-branch

我想知道这两个git命令是否完全相同?

git clone git://git.yoctoproject.org/poky --branch daisy

git clone -b daisy git://git.yoctoproject.org/poky.git

1 个答案:

答案 0 :(得分:1)

根据git手册页,theese命令是相同的:

$ git help clone
 ....
 --branch <name>, -b <name>
 Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare
 repository, this is the branch that will be checked out.  --branch can also take tags and detaches the HEAD at that commit in the resulting
repository.
 ....

正如您所看到的,-b--branch只是同义词。缺少扩展.git(在第一种情况下)是自动确定的(考虑到协议git://)并且参数的顺序无关紧要。