Re: best way to fastforward all tracking branches after a fetch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/11/2011 03:22 AM, Sitaram Chamarty wrote:
> On Sat, Dec 10, 2011 at 01:26:32PM +0100, Gelonida N wrote:
>> Hi,
>>
>> What is the best way to fastforward all fastforwardable tracking
>> branches after a git fetch?
> 
> I dont think there is a single command to do it for *all*
> branches, but for any particular branch, this should work:

A tiny script is fine. I didn't really expect the magic command.

Currently I'm using one script per repository, which hard coded the
branches,
that I want to fast-forward (checking them out and doing a git-pull)

> 
>     git merge --ff-only @{u}
> 
Thanks, '--ff=only @{u}'  is already the first improvement for my script.


> So what you want would boil down to this script (untested):
> 
>     #!/bin/bash
>     git status --porcelain -uno | grep . && {echo dirty tree, exiting...; exit 1; }
> 
>     for b in `git for-each-ref '--format=%(refname:short)' refs/heads`
>     do
>         git checkout $b
>         git merge --ff-only @{u}
>     done



Is there no way to distinguish tracking branches from other branches?
without checking them out?

In order to save time I'd like to avoid checking out local branches.

Ideally I would even like to avoid checking out branches, which don't
need to be forwarded.


I also had to remember on which branch I was in order to avoid, that I
am at a random branch after running the script.

I could imagine something like my snippet below , though I guess,
there's something more elegant.

git stash
mybranch=`git branch | sed -n 's/\* *//p'`
# do_script . . .
git checkout $mybranch
git stash apply





--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]