Re: best way to fastforward all tracking branches after a fetch
Show 9 quoted lines
> Jakub Narebski <jnareb@gmail.com> 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
Show 6 quoted lines
> > # 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