Reputation: 222
I have a repository that I cloned with the --single-branch
option. Now someone else created a new branch that I need to pull for my particular work on this repository.
I know that the single branch option adds a line like
fetch = +refs/heads/master:refs/remotes/origin/master
to the git configuration with a specific branch name instead of a *
and I could simply add another line like this to config. But there is also a way to achieve this through a single git command - I used it in the past, I just absolutely don't remember which command does this. Would be great if someone could jog my memory.
Upvotes: 1
Views: 86
Reputation: 222
In the meantime I found the command I tried to remember: To add another branch to fetch without having to specify refspecs manually one can use the set-branches
sub-command of git remote
:
$ git remote set-branches --add <remote> <branch>
This adds the proper refspec to the remote's configuration. The --add
option is quite important here because without it the new branch would replace the currently configured ones.
Upvotes: 1
Reputation: 30888
The line is to configure a refspec. You can specify it in the command.
git fetch origin +refs/heads/foo:refs/remotes/origin/foo
Upvotes: 2