All of lore.kernel.org
 help / color / mirror / Atom feed
* Where/how to create tracking branches?
@ 2007-02-19 16:45 Bill Lear
  2007-02-19 19:43 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Bill Lear @ 2007-02-19 16:45 UTC (permalink / raw)
  To: git

What is the recommended way to create tracking branches in my private
repo if I first create the corresponding topic branch in my private
repo and want to publish it via a public repo?

Scenario:

[my private repo]
% git checkout -b topic
[work, work, work, commit]
% git push /public/repo/project topic:topic

[somebody else:]
% git clone /public/repo/project
% git checkout -b topic origin/topic
[work, work, work, commit]
% git push /public/repo/project topic:topic

[my private repo]
% git checkout topic
% git pull /public/repo/project topic
remote: Generating pack...
remote: Done counting 5 objects.
Result has 3 objects.
remote: Deltifying 3 objects.
remote: /3) done/3) done
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking 3 objects
 100% (3/3) done
Updating 4751fcc..2d92737
Fast forward
 A |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
% git branch
  master
* topic
% git branch -r
  origin/HEAD
  origin/master

Now, I'm on my private repo, but I really want a tracking branch for
doing pulls from my public repo, or peers, for this topic branch.

Do I have to create the topic branch in my public repo first?  This
seems crazy, as our company repo is just another "global" public repo
and each developer would need to create branches there instead of on
their own machine.

I tried this:

% git pull /public/repo/project topic:origin/topic

But it created a topic branch named "origin/topic" instead of a tracking
branch.


Bill

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Where/how to create tracking branches?
  2007-02-19 16:45 Where/how to create tracking branches? Bill Lear
@ 2007-02-19 19:43 ` Junio C Hamano
  2007-02-19 20:13   ` Bill Lear
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-02-19 19:43 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

Bill Lear <rael@zopyra.com> writes:

> What is the recommended way to create tracking branches in my private
> repo if I first create the corresponding topic branch in my private
> repo and want to publish it via a public repo?
>
> Scenario:
>
> [my private repo]
> % git checkout -b topic
> [work, work, work, commit]
> % git push /public/repo/project topic:topic

So at this point the public shared repository has refs/heads/topic
branch you and colleagues can work on together.  So I am puzzled
about this part...

> Do I have to create the topic branch in my public repo first?  This
> seems crazy,...

because you did do so and I do not think it is crazy.

Maybe you meant "do I create tracking branch for 'topic' in public?",
in which case the answer is no.

> I tried this:
>
> % git pull /public/repo/project topic:origin/topic
>
> But it created a topic branch named "origin/topic" instead of a tracking
> branch.

Assuming your clone was initially made from /public/repo/project,
doesn't "git fetch" without _any_ parameter work?

	$ git fetch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Where/how to create tracking branches?
  2007-02-19 19:43 ` Junio C Hamano
@ 2007-02-19 20:13   ` Bill Lear
  2007-02-19 21:09     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Bill Lear @ 2007-02-19 20:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Monday, February 19, 2007 at 11:43:36 (-0800) Junio C Hamano writes:
>...
>Assuming your clone was initially made from /public/repo/project,
>doesn't "git fetch" without _any_ parameter work?
>
>	$ git fetch

Short answer: yes, it does.  I had assumed I needed to create the
tracking branch somehow since I created the topic branch in the first
place in my private repo.  More detailed confirmation follows, but
thank you for pointing out that git is in fact smarter than I gave
it credit.

# set up a public repo with "master" branch and something in it...
mkdir public_repo && cd public_repo && git --bare init
cd ..
mkdir a_repo && cd a_repo && git init
echo A > A && git add A && git commit -a -m A
git push ../public_repo master:master

# clone public repo to get my private repo, create topic branch
cd ..
git clone public_repo private_repo
cd private_repo
git checkout -b topic
echo change >> A && git commit -a -m change

# publish my branch 'topic' to my public repo
git push ../public_repo topic:topic

# A peer grabs the topic branch, makes changes and pushes back to public
cd ..
git clone public_repo peer_repo
cd peer_repo
git checkout -b topic origin/topic
echo more >> A && git commit -a -m more
git push ../public_repo topic:topic

# Go to my private repo, pull latest changes (show output this time...)
cd ../private_repo
git checkout master
git pull
remote: Generating pack...
remote: Done counting 5 objects.
Result has 3 objects.
remote: Deltifying 3 objects.
remote: /3) done/3) done
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking 3 objects
 100% (3/3) done
* refs/remotes/origin/topic: storing branch 'topic' of /home/blear/test/public_repo
  commit: 4a8e157
Already up-to-date.

# Now, switch to topic branch
git checkout topic
cat A
A
change

# Ok, now I get it:
git diff origin/topic
[changes listed]
git merge origin/topic
cat A
A
change
more


Bill

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Where/how to create tracking branches?
  2007-02-19 20:13   ` Bill Lear
@ 2007-02-19 21:09     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-02-19 21:09 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

Bill Lear <rael@zopyra.com> writes:

> On Monday, February 19, 2007 at 11:43:36 (-0800) Junio C Hamano writes:
>>...
>>Assuming your clone was initially made from /public/repo/project,
>>doesn't "git fetch" without _any_ parameter work?
>>
>>	$ git fetch
>
> Short answer: yes, it does.  I had assumed I needed to create the
> tracking branch somehow since I created the topic branch in the first
> place in my private repo.  More detailed confirmation follows, but
> thank you for pointing out that git is in fact smarter than I gave
> it credit.

Tracking new branches on the remote side after you create a
clone is one of the few things 1.5.0 does much better than 1.4.4
series, and it was done in response to comments from real world
users like yourself, so rather than giving git too much credit,
I think you should take it yourself ;-).

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-19 21:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 16:45 Where/how to create tracking branches? Bill Lear
2007-02-19 19:43 ` Junio C Hamano
2007-02-19 20:13   ` Bill Lear
2007-02-19 21:09     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.