git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Where/how to create tracking branches?

From
Bill Lear <rael@zopyra.com>
Date
Feb 19, 2007, 20:13 UTC
Message-ID
<17882.1230.704770.12880@lisa.zopyra.com>
In-Reply-To
<7vy7mu6ihj.fsf@assigned-by-dhcp.cox.net>
On Monday, February 19, 2007 at 11:43:36 (-0800) Junio C Hamano writes:
Show 5 quoted lines
>...
>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
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “Where/how to create tracking branches?”
  1. Bill LearFeb 19, 2007
  2. Junio C HamanoFeb 19, 2007
  3. Bill LearFeb 19, 2007
  4. Junio C HamanoFeb 19, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.