I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches.
Updating all my local branches is tedious:
git fetch --all
git rebase origin/master
git checkout staging
git rebase origin/staging
git checkout production
git rebase origin/production
I'd love to be able to just do a "git pull -all", but I haven't been able to get it to work. It seems to do a "fetch --all", then updates (fast forward or merges) the current working branch, but not the other local branches.
I'm still stuck manually switching to each local branch and updating.
Just posting an updated answer.
git-up
is no longer maintained and if you read the documentation, they mention the functionality is now available in git.You can also set this for every
git pull
as of Git 2.9 as well (thanks @VonC please see his answer here)A slightly different script that only fast-forwards branches who's names matches their upstream branch. It also updates the current branch if fast-forward is possible.
Make sure all your branches' upstream branches are set correctly by running
git branch -vv
. Set the upstream branch withgit branch -u origin/yourbanchname
Copy-paste into a file and chmod 755: