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

Re: [Newbie] How to *actually* get rid of remote tracking branch?

From
Steffen Prohaska <prohaska@zib.de>
Date
Nov 14, 2007, 05:48 UTC
Message-ID
<D1F72A32-2EE2-4CC9-AC0F-CDB3A261DEA7@zib.de>
In-Reply-To
<473A493C.4070902@op5.se>
On Nov 14, 2007, at 2:02 AM, Andreas Ericsson wrote:
Show 25 quoted lines
>> BTW, when you have this data-flow (probably typical in a shared
>> repository workflow):
>>     Remote repository               Your repository
>>     refs/heads/foo -------(A)------> refs/remotes/origin/foo
>>          ^                                |
>>          |                               (B)
>>          |                                |
>>          |                                V
>>          `-------------(C)---------- refs/heads/foo
>>          (A) "git fetch" with remote.origin.fetch configuration
>>              set to +refs/heads/*:refs/remotes/origin/* keeps
>>              your refs/remotes/origin/foo up-to-date with their
>>              refs/heads/foo
>>          (B) "git merge origin/foo" while on "foo" branch (there
>>              are few shorthands like "git pull origin foo" while
>>              on "foo" branch.  If you say "git branch --track
>>              foo origin/foo", then running "git pull" without
>>              parameter while on "foo" branch).
>>          (C) "git push origin foo".
>>  * Everybody seems to agree that "refs/remotes/origin/foo" is
>>    called a "remote tracking branch";
>
> I'd like to insert the significant dash there. remote-tracking vs
> remote tracking. It solves the one ambiguity with it, and would
> finally make it clear and consistent almost however it's used.
I recently tried to explain it in the following way:

"refs/remotes/origin/foo" mirrors the original branch (from the remote repository) in your local repository. Because it is an identical copy of the branch in the remote repository it is also called a "remote-tracking branch" or sometimes just a "remote branch", although it is stored locally in your repository.

Show 5 quoted lines
>>  * Your refs/heads/foo follows and builds on top of 'foo' branch
>>    at the remote.  Some people errorneously call it "tracking"
>>    but that is because we do not have a good term for it;
>
> "private tracking branch"? Nah...

"refs/heads/foo" is your local branch that you work on. Typically, it's simply called branch foo. However you can say "my local branch" foo to emphasis that it's your branch. This branch is set up in a way to automatically merge changes from the remote branch it was created from. It is sometimes said to "track" a remote branch, however it must not be confused with a "remote-tracking branch". The terminology used in the documentation is sometimes confusing. A clear statement is: "My local branch foo is configured to automatically merge the remote (tracking) branch origin/foo, with origin configured to point to git://server/path/to/repo.git."

Show 5 quoted lines
>>  * There is no good name for "refs/heads/foo at the remote".  We
>>    always say "the remote branch you follow" (or "track").
>
> "remote-repo branch" perhaps? The universe doesn't exactly toll its
> bells in approval at that, but at least it's not ambiguous.

Typically, the original branch in the remote repository and its local remote-tracking branch point to the same commit; or you can easy update the local copy with fetch. So, often they are not distinguished. But you can say "branch foo from the remote repository git://server/path/to/repo.git" is mirrored locally as "remote-tracking branch origin/foo" if you need to be precise.

If you say "I merged origin/foo" it really does not matter if you mean the branch in the remote repository or its local remote-tracking branch. In both cases the reader needs context to understand what you exactly mean. If you want to be precise here, you can say "I merged commit <sha1>".

A technical note: The '--track' option sets up the local branch to track the original branch in the remote repository. The setup is not referring to a local remote-tracking branch at all. config.<branch>.merge contains the branch as it is named in the remote repository. git is automatically merging from the branch in the remote repository. The remote-tracking branch would not be needed to do this. So I think it's not a problem that "remote branch foo" sometimes means the branch in the remote repository and sometimes means its local remote-tracking branch. What you really mean in both cases is the original branch in the remote repository. If you want to explicitly point to a specific commit you need to name it by other means (sha1) anyway.

> I've seen it written as "remote tracking branch" on irc a few times.
> It causes 10 minutes of confusion where no-one's sure what anyone
> else means. With the dash in there, there's no room for ambiguity.
I believe dash is a good idea.
	Steffen
Previous: Andreas EricssonNext: Sergei Organov
Message 26 of 28 in “[Newbie] How to *actually* get rid of remote tracking branch?”
  1. Sergei OrganovNov 13, 2007
  2. Jakub NarebskiNov 13, 2007
  3. Sergei OrganovNov 13, 2007
  4. Johannes SchindelinNov 13, 2007
  5. Sergei OrganovNov 13, 2007
  6. Johannes SchindelinNov 13, 2007
  7. Sergei OrganovNov 13, 2007
  8. Jan HudecNov 17, 2007
  9. Jakub NarebskiNov 13, 2007
  10. Steffen ProhaskaNov 13, 2007
  11. Jakub NarebskiNov 13, 2007
  12. osv@javad.comNov 13, 2007
  13. Lars HjemliNov 13, 2007
  14. Sergei OrganovNov 13, 2007
  15. Steffen ProhaskaNov 13, 2007
  16. Jan HudecNov 17, 2007
  17. Improve description of git-branch -d and -D in man page.Jan Hudec, Nov 17, 2007
  18. Sergei OrganovNov 19, 2007
  19. Sergei OrganovNov 13, 2007
  20. Andreas EricssonNov 13, 2007
  21. Andreas EricssonNov 13, 2007
  22. Jakub NarebskiNov 13, 2007
  23. J. Bruce FieldsNov 13, 2007
  24. Junio C HamanoNov 13, 2007
  25. Andreas EricssonNov 14, 2007
  26. Steffen ProhaskaNov 14, 2007
  27. Sergei OrganovNov 13, 2007
  28. Jakub NarebskiNov 13, 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.