Home > Software design >  Clone another branch after cloning single-branch
Clone another branch after cloning single-branch

Time:12-18

I'm using the below command to clone one branch:

git clone user@git-server:project_name.git -b branch_name --single-branch /your/folder

Now I want to check out another branch from the server. I tried the below command and it didn't work

git checkout another_branch

After cloning a single branch, how can I clone/checkout/pull/fetch another branch?

CodePudding user response:

You can fetch another remote branch by specifying it after the remote name in a git fetch call:

git fetch origin another_branch

Once it's fetched, you'll find it in the FETCH_HEAD, and an use that to create a local branch:

git checkout FETCH_HEAD -b another_branch
  • Related