git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khomoutov <kostix+git@007spb.ru>
To: "Jan Pešta" <jan.pesta@certicon.cz>
Cc: <git@vger.kernel.org>
Subject: Re: Updating not actual branch
Date: Tue, 12 Mar 2013 19:19:36 +0400	[thread overview]
Message-ID: <20130312191936.d25cbca4934a8c92b7ec0542@domain007.com> (raw)
In-Reply-To: <006501ce1f24$94636a30$bd2a3e90$@certicon.cz>

On Tue, 12 Mar 2013 14:22:00 +0100
Jan Pešta <jan.pesta@certicon.cz> wrote:

> I have a question if there is a posibility tu update a branch which
> is not actual working copy.
> 
> I have following situation:
> 
> A - B - C - I - J                       master
>                \ - D - E - F               feature 1
>                                  \ G - H     feature 2 (working copy)
> 
> I would like tu update whole tree with latest changes in master
> 
> A - B - C - I - J                                              master
>                            \ - D* - E* - F*                  feature 1
>                                                    \ G* - H*
> feature 2 (working copy)
> 
> 
> Is there some way how to do it without swithing to each branch and
> update them manually?

It's partially possible to do: you are able to forcibly fetch a remote
object into any local branch provided it's not checked out.  Hence, in
your case you'll be able to update any branch excapt for "feature 2".

To do this, you could use the explicit refspec when fetching, like this:

$ git fetch origin +src1:dst1 '+blooper 1:feature 1'

(Consult the `git fetch` manual for more info on using refspecs.)

One possible downside is that I'm not sure this approach would play
nicely with remote branches, if you have any.  I mean, direct fetching
into local branches will unlikely to update their matching "upstream"
remote branches.

So supposedly a better way to go would be to write a script which would
go like this:
1) Do a simple one-argument `git fetch <remotename>` to fetch from
   the specified remote and update its remote branches.
2) Run `git for-each-ref`, and for each local branch found first check
   whether it's currently checked out (that is, HEAD points at it)
   and ignore the branch if it is; otherwise do `git update-ref`
   updating the branch pointer from its upstream branch -- referring to
   that using the <ref>@{upstream} syntax.
   (Consult the gitrevisions manual for more info on this syntax.)

  reply	other threads:[~2013-03-12 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 13:22 Updating not actual branch Jan Pešta
2013-03-12 15:19 ` Konstantin Khomoutov [this message]
2013-03-12 16:03 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130312191936.d25cbca4934a8c92b7ec0542@domain007.com \
    --to=kostix+git@007spb.ru \
    --cc=git@vger.kernel.org \
    --cc=jan.pesta@certicon.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).