2

I have a remote repo I cloned a while ago. Local .config has this:

[remote "origin"]
    url = ...
    fetch = +refs/heads/branch1:refs/remotes/origin/branch1
[branch "branch1"]
    remote = origin
    merge = refs/heads/branch1

Now I know that my coworkers have created a new remote branch - "branch2". I want to fetch it and then checkout. Also I don't want to fetch all the branches - only the new one. The only way I know is modifying .config by adding

fetch = +refs/heads/branch2:refs/remotes/origin/branch2

and then do "git pull"

Is there a way to add fetching new branch through git command? I don't want to edit config every time I need a new branch.

Dmitriy M
  • 297
  • 1
  • 2
  • 7
  • Just curious, why would you want to only fetch one branch? – Jeff Puckett Jul 16 '16 at 17:37
  • 1
    remote repo is very big (about 50gb) and I don't need all the extra branches I'm not working with – Dmitriy M Jul 17 '16 at 18:32
  • 1
    The specific answer is: `git remote set-branches --add origin branch2`. Unfortunately this question has been closed flippantly (the answer could just be guessed from a variant of a low-ranked answer deep down in the other thread - the question there is rather the opposite question.). – kxr Aug 29 '20 at 09:20

0 Answers0