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

[gits] Two Branches, same name



On Wed, Dec 18, 2013 at 11:24:59PM -0700, Eric Eide wrote:
> 	Gary> How about just:
> 	Gary> 
> 	Gary>     $ git remote add kdownie git-public.flux.utah.edu:...
> 	Gary>     $ git checkout --orphan kaptui
> 	Gary>     $ git pull kdownie aptui
> 
> Erk.  I'm not sure I understand this; I guess an experiment is in order.

It's a two-step solution:

 1) Create (and change to) an empty branch.

 2) Yank Keith's work into it.

It was the only way I could think of to avoid an explicit fetch step -- the
trouble is the chicken-and-egg problem of (a) needing to know where to
start the branch (which you might like to be the last common ancestor
of wherever you are and wherever Keith is -- but that can't be determined
without retrieving history from Keith's repository) and (b) actually
grabbing commits from Keith and applying them to the local branch (which
can't be done until the local branch is created).

Normally you you could resolve the problem with an intermediate fetch
step (because the fetch will tell you everything you need about Keith's
state without trying to apply it anywhere), but that is exactly what you
asked to avoid.

So instead, the "checkout --orphan" was the first option I could think
of that simultaneously satisfies (a) it can be generated without any
remote information at all, and (b) is trivially guaranteed to be
fast-forwardable to whatever subsequently turns out to be Keith's
branch's HEAD (still unknown at this point).

> Even if you clear the index after running the checkout --- "git rm
> -rf ." --- you would still end up in a state where the local kaptui
> branch isn't tracking Keith's aptui branch.  Yes?

Yes, quite true.  I guessed from Leigh's earlier message that he didn't
really care about tracking Keith's branch, and just wanted to look at
the code.  If you had followed the above procedure and then decided you
wanted to track after all, you could do it with:

    $ git remote set-branches kdownie aptui
    $ git fetch kdownie
    $ git branch --set-upstream kaptui kdownie/aptui

(That does involve an explicit "git fetch", but I don't know how to
avoid it in this case.)

Bye for now,
Gary.
-- 
       Gary Wong      gtw at flux.utah.edu      http://www.cs.utah.edu/~gtw/