From: Jakub Narebski Date: Sun, 11 Dec 2011 19:53:05 GMT Subject: Re: best way to fastforward all tracking branches after a fetch Message-ID: <201112112053.07548.jnareb@gmail.com> In-Reply-To: Andreas Schwab wrote: > Jakub Narebski writes: > > > Something like > > > > git for-each-ref '--format=%(refname) %(upstream)' | > > while read refname upstream > > do > > # there is upstream > > test -n "$upstream" || break Here you should probably also check if we are already up-to-date: test $(git rev-parse $upstream) = $(git rev-parse $refname) || continue > > # and if fast-forwards > > test $(git merge-base $refname $upstream) = $(git rev-parse $refname) || break > > git update-ref -m "$message" $refname $upstream > > done > > You probably meant s/break/continue/. Yes, sorry about that. BTW. git-update-ref invocation can be replaced by Sitaram's suggestion: git branch -f $refname $upstream -- Jakub Narebski Poland