Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git fetch another branch after cloning a single branch

Tags:

git

github

I am working in a system that automatically git clones using the --branch arg like so:

git clone --branch master --depth 50 [email protected]:Something/Cool.git ~/Cool

And I would now like to push to another branch. I can't figure out how to track the remote since git fetch and git pull don't seem to be able to access them.

like image 437
creatorjames Avatar asked Feb 06 '14 07:02

creatorjames


1 Answers

I ended up modifying the config for each branch (or branch glob) I want to fetch. Expressed as an alias:

[alias]
    # Usage: git add-fetch-branch REMOTE BRANCH
    add-fetch-branch = !sh -c 'git config --add remote.$0.fetch "refs/heads/$1:refs/remotes/$0/$1"'
like image 80
Leif Arne Storset Avatar answered Nov 01 '22 11:11

Leif Arne Storset