Track all remote git branches as local branches

Tracking a single remote branch as a local branch is straightforward enough.

$ git checkout --track -b ${branch_name} origin/${branch_name}

Pushing all local branches up to the remote, creating new remote branches as needed is also easy.

$ git push --all origin

I want to do the reverse. If I have X number of remote branches at a single source:

$ git branch -r 
branch1
branch2
branch3
.
.
.

Can I create local tracking branches for all those remote branches without needed to manually create each one? Say something like:

$ git checkout --track -b --all origin

I’ve googled and RTMs, but have come up bunk thus far.

16 Answers
16

Leave a Comment