Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This assumes your "upstream" remote is named "origin" and you have your custom fork under your username (i.e. "maxandersen")</p> <p>When you have your clone run the following one-liner (refresh of <a href="https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches/6300386#6300386">Track all remote git branches as local branches</a> :</p> <pre><code>remote=origin ; for brname in `git branch -r | grep origin | grep -v master | grep -v HEAD | sed -e 's/.*\///g'`; do git branch --track $brname $remote/$brname ; done </code></pre> <p>This will setup tracking branches for all the branches found in the remote named 'origin'. If you already have a checkout with this branchname it will not change anything except ensure the tracking is in place.</p> <p>(Optional) Now ensure all your branches are uptodate (useful if you have already branches checked out):</p> <pre><code>git pull --rebase --all </code></pre> <p>Now with all branches setup for tracking and uptodate push branches <em>and</em> tags to your remote (replace 'maxandersen' with your remote name):</p> <pre><code>git push --all maxandersen git push --tags maxandersen </code></pre> <p>After this your fork is in sync.</p> <p>The following script does all this including asking for confirmation:</p> <pre><code>## Checkout all branches from remote as tracking branches. Based on https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches/6300386#6300386 UPSTREAM=$1 MYREPO=$2 usage() { echo "Usage:" echo "$0 &lt;upstream-remote&gt; &lt;target-remote&gt;" echo "" echo "Example which ensures remote named 'maxandersen' have all the same branches and tags as 'origin'" echo "$0 origin maxandersen" exit 1 } if [ -z "$UPSTREAM" ] then echo Missing upstream remote name. usage fi if [ -z "$MYREPO" ] then echo Missing target remote name. usage fi read -p "1. This will setup '$MYREPO' to track all branches in '$UPSTREAM' - Are you sure ?" -n 1 -r if [[ $REPLY =~ ^[Yy]$ ]] then for brname in `git branch -r | grep "$UPSTREAM" | grep -v master | grep -v HEAD | sed -e 's/.*\///g'`; do git branch --track $brname $UPSTREAM/$brname ; done fi read -p "2. This will push all local branches and tags into '$MYREPO' - Are you sure ?" -n 1 -r if [[ $REPLY =~ ^[Yy]$ ]] then git push --all $MYREPO git push --tags $MYREPO fi </code></pre> <p>Save it as 'updateallbranchestags.sh' and execute it with:</p> <pre><code>sh updateallbranches.sh origin maxandersen </code></pre> <p>And all branches/tags from 'origin' will be made available in remote named 'maxandersen'</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload