Search code examples
gitgit-branchgit-clonegit-checkout

Git command equivalent


is

git clone -b branch1 ssh://gitolite@host/project/testkit

equivalent to

git clone ssh://gitolite@host/project/testkit
cd testkit
git checkout branch1

?


Solution

  • Yes, this is supported by the git clone documentation:

    -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.