1

so I have some repository, in that repo have master and other branches ( or we can call branch a, branch b, branch c)

I want to pull branch C, how can I do that?

I'm using command line and git

2 Answers2

1

You can do:

git pull origin c

then checkout the branch

git checkout c
MaskedHero
  • 34
  • 3
  • git pull does a fetch and then a merge, which in this case would mean that branch "c" would get merged into whatever branch the user currently has checked out. That is not what is wanted here. Better to do "git fetch c" followed by "git checkout c". But better yet, follow the advice of VonC, above. – Randy Leberknight Dec 29 '21 at 21:04
1

Try and use git switch, not the old obsolete and confusing git checkout command.

git fetch
git switch c

That is because, from guess mode:

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to

git switch -c <branch> --track <remote>/<branch>
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250