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

Re: Git terminology: remote, add, track, stage, etc.

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Oct 18, 2010, 21:41 UTC
Message-ID
<vpq8w1v5gce.fsf@bauges.imag.fr>
In-Reply-To
<8835ADF9-45E5-4A26-9F7F-A72ECC065BB2@gmail.com>
Thore Husfeldt <thore.husfeldt@gmail.com> writes:
> Read it as the friendly, but
> somewhat exasparated suggestions of a newcomer. I’d love to help (in
> the form of submitting patches to the documentation or CLI responses),
> but I’d like to test the waters first.
(it's common practice here to test the water with RFC/PATCHes too)
> There are at least two uses of the word *tracking* in Git's
> terminology.
Actually, there's a third, known to be rather unfortunate.
For example, when you clone a repository, by default, you end up with
1) The master branch hosted remotely
2) origin/master, locally, but "remote-tracking"
3) master, your working branch.

When you do a "git pull" when sitting on local branch master, Git knows it must :

a) fetch (i.e. download) from branch 1) into branch 2) b) merge from branch 2) into branch 1)

Rule a) come from remote.<remotename>.fetch, and rule b) comes from branch.master.merge in your .git/config.

Usually, we refer to tracking branch to mean rule a), but the "track" in "git branch --track" means "setup git for rule b) above".

We already came up with a better wording, namely "upstream", and used in in "git push --set-upstream". Probably a next step would be to deprecate any other occurence of --track meaning the same thing (git checkout --track seems to me to be a candidate, git branch has both --track and --set-upstream). One difficulty is to do that with backward compatibility in mind.

> 3. Duplicate various occurences of `cached` flags as `staged` (and
> change the documentation and man pages accordingly), so as to have,
> e.g., `git diff --staged`.

I do like this, but to be complete, one should also deal with more complex cases. For example, "git apply" has _both_ --index and --cached, with different semantics.

And changing just _some_ of the occurences of --index and --cached may help, but do not fix the problem of inconsistancies. Up to now, there have been many efforts towards consistancy, but I guess no one had the courrage of doing a global-enough approach to eliminate all inconsistancies.

In other words, I encourage you to continue the effort you've stated here, but that won't help much unless you push the idea far enough IMHO.

>     changed but not updated:
>
> I’m still not sure what “update” was ever supposed to mean in this
> sentence.

Historically, the staging area was seen as a cache (hence the name), which was purposedly out-of-date when doing a partial commit. Hence, Git inherited some of the terminology of usual caches (a cache is "dirty" when it's not in sync with what it caches, "clean" when it is, and you "update" it to make it in sync).

But I do agree that the analogy with a cache is disturbing for the user, even if it's meaningful for the developper: as a user, a cache is meant to be a performance optimization, not supposed to interfer with the functionality.

Show 8 quoted lines
> 2.
>     Untracked files:
>     (use "git add <file>..." to include in what will be committed)
>
> should be
>
>     Untracked files:
>     (use "git track <file>" to track)

This hypothetical "git track" actually exists under the name "git add -N".

> The opposite of staging is `git
> reset HEAD <file>` and the opposite of tracking is -- well, I’m not
> sure, actually. Maybe `git update-index --force-remove <filename>`?
git rm --cached ?

As a bare mortal, you shouldn't need update-index, it's a plumbing command (i.e. meant for scripts or low-level manipulations).

> An even more radical suggestion (which would take all of 20 seconds to
> implement) is to introduce `git track` as another alias for `git
> add`. (See above under `git status`). This would be especially useful
> if tracking *branches* no longer existed.

I disagree that adding aliases would help users. See your confusion, and then the relief when you found out that index, cache, and staging area were synonymous. Now, what should a user think after learning stage, track and add, and asking for the difference.

I agree that adding new files and adding new content to existing files are done for different reasons, but the conceptual simplicity of Git comes from the fact that Git is purely snapshot oriented, and I to some extent, it's nice to have this reflected in the user-interface.

When you say "git add X", you don't talk about the difference between the previous commit and the next, or about the difference between working tree and next commit, or so. You're basically saying "file X will exist in the next commit, and it will have this content". Whether it existed or not in the previous commit doesn't matter. It's implemented this way, and it's really something fundamental in the Git model.

> There’s another issue with this, namely that “added files are
> immediately staged”. In fact, I do understand why Git does that, but
> conceptually it’s pure evil: one of the conceptual conrnerstones of
> Git -- that files can be tracked and changed yet not staged,

Rephrase that as "the working tree can have content different from the staged content". Both "working tree content" and "staged content" are snapshot (i.e. they exist regardless of each other). Then newly created files won't be different anymore. Files exist, with some (possibly empty) content, or they don't.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Matthieu MoyNext: Miles Bader
Message 30 of 59 in “Git terminology: remote, add, track, stage, etc.”
  1. Thore HusfeldtOct 18, 2010
  2. Jonathan NiederOct 18, 2010
  3. reset: accept "git reset <removed file>"Jonathan Nieder, Oct 18, 2010
  4. Junio C HamanoOct 18, 2010
  5. Jonathan NiederOct 19, 2010
  6. Junio C HamanoOct 19, 2010
  7. Jonathan NiederOct 19, 2010
  8. Sverre RabbelierOct 18, 2010
  9. Junio C HamanoOct 19, 2010
  10. Ramkumar RamachandraOct 19, 2010
  11. Jonathan NiederOct 19, 2010
  12. Sverre RabbelierOct 19, 2010
  13. Thore HusfeldtOct 19, 2010
  14. User manual: "You cannot check out these remote-tracking branches"Jonathan Nieder, Oct 19, 2010
  15. Matthieu MoyOct 19, 2010
  16. Nicolas PitreOct 19, 2010
  17. Junio C HamanoOct 19, 2010
  18. 0/4 reset: be more flexible about <rev>Jonathan Nieder, Oct 19, 2010
  19. 1/4 reset -p: accept "git reset -p <tree>"Jonathan Nieder, Oct 19, 2010
  20. 2/4 reset: accept "git reset <tree> <path>"Jonathan Nieder, Oct 19, 2010
  21. 3/4 reset: accept "git reset -- <path>" from unborn branchJonathan Nieder, Oct 19, 2010
  22. 4/4 reset: accept "git reset HEAD <path>" from unborn branchJonathan Nieder, Oct 19, 2010
  23. Junio C HamanoOct 19, 2010
  24. Jonathan NiederOct 19, 2010
  25. Ramkumar RamachandraOct 27, 2010
  26. Drew NorthupOct 27, 2010
  27. Matthieu MoyOct 27, 2010
  28. Ramkumar RamachandraOct 28, 2010
  29. Matthieu MoyOct 28, 2010
  30. Matthieu MoyOct 18, 2010
  31. Miles BaderOct 19, 2010
  32. Wincent ColaiutaOct 19, 2010
  33. Miles BaderOct 19, 2010
  34. Wincent ColaiutaOct 19, 2010
  35. Eugene SajineOct 19, 2010
  36. Paul BolleOct 22, 2010
  37. Eugene SajineOct 22, 2010
  38. Drew NorthupOct 22, 2010
  39. Thore HusfeldtOct 20, 2010
  40. Matthieu MoyOct 20, 2010
  41. Drew NorthupOct 20, 2010
  42. Jakub NarebskiOct 18, 2010
  43. Matthijs KooijmanOct 19, 2010
  44. Jakub NarebskiOct 19, 2010
  45. Thore HusfeldtOct 19, 2010
  46. Jakub NarebskiOct 19, 2010
  47. Michael HaggertyOct 21, 2010
  48. Drew NorthupOct 21, 2010
  49. Thore HusfeldtOct 21, 2010
  50. Drew NorthupOct 21, 2010
  51. Thore HusfeldtOct 21, 2010
  52. Drew NorthupOct 21, 2010
  53. Miles BaderOct 22, 2010
  54. Drew NorthupOct 22, 2010
  55. Porcelain scripts: Rewrite cryptic "needs update" error messageRamkumar Ramachandra, Oct 19, 2010
  56. Ramkumar RamachandraOct 27, 2010
  57. Junio C HamanoNov 5, 2010
  58. Ævar Arnfjörð BjarmasonFeb 12, 2011
  59. Drew NorthupOct 19, 2010

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.