As I can see from your example, you are actually trying to synchronize the local branchname branch with origin / branchname
You do not need any additional scripts for this, you just need to use git pull instead of the git checkout branchname; git fetch origin; git merge origin/branchname git checkout branchname; git fetch origin; git merge origin/branchname
take a look at the git branch tracking docs and their benefits.
generally speaking, if you have a repo layout:
git branch -a ... master dev1 dev2 remotes/origin/master remotes/origin/dev1 remotes/origin/dev2
And your branches dev1 and dev2 track the branches for origin / dev1 and origin / dev2 respectively, then you just need to execute in the repository:
git pull
This command will effectively synchronize all local tracking branches with remote ones.
See here for more details:
Git pull docs
Git remote branches and tracking branches (Progit book)
Eugene Sajine Mar 23 '11 at 16:32 2011-03-23 16:32
source share