git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Thore Husfeldt <thore.husfeldt@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Git terminology: remote, add, track, stage, etc.
Date: Mon, 18 Oct 2010 23:41:21 +0200	[thread overview]
Message-ID: <vpq8w1v5gce.fsf@bauges.imag.fr> (raw)
In-Reply-To: <8835ADF9-45E5-4A26-9F7F-A72ECC065BB2@gmail.com> (Thore Husfeldt's message of "Mon\, 18 Oct 2010 22\:45\:50 +0200")

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.

> 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/

  parent reply	other threads:[~2010-10-18 21:44 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18 20:45 Git terminology: remote, add, track, stage, etc Thore Husfeldt
2010-10-18 21:15 ` Jonathan Nieder
2010-10-18 22:48   ` [RFC/PATCH] reset: accept "git reset <removed file>" Jonathan Nieder
2010-10-18 23:56     ` Junio C Hamano
2010-10-19  0:23       ` Jonathan Nieder
2010-10-19 17:34         ` Junio C Hamano
2010-10-19 22:34           ` Jonathan Nieder
2010-10-18 21:35 ` Git terminology: remote, add, track, stage, etc Sverre Rabbelier
2010-10-19  0:03   ` Junio C Hamano
2010-10-19 17:51   ` Ramkumar Ramachandra
2010-10-19 18:28     ` Jonathan Nieder
2010-10-19 18:34       ` Sverre Rabbelier
2010-10-19 18:43         ` Thore Husfeldt
2010-10-19 19:04           ` User manual: "You cannot check out these remote-tracking branches" Jonathan Nieder
2010-10-19 20:52             ` Matthieu Moy
2010-10-19 19:15           ` Git terminology: remote, add, track, stage, etc Nicolas Pitre
2010-10-19 19:20       ` Junio C Hamano
2010-10-19 22:10         ` [RFC/PATCH 0/4] reset: be more flexible about <rev> Jonathan Nieder
2010-10-19 22:11           ` [WIP/PATCH 1/4] reset -p: accept "git reset -p <tree>" Jonathan Nieder
2010-10-19 22:12           ` [PATCH 2/4] reset: accept "git reset <tree> <path>" Jonathan Nieder
2010-10-19 22:13           ` [PATCH 3/4] reset: accept "git reset -- <path>" from unborn branch Jonathan Nieder
2010-10-19 22:14           ` [PATCH 4/4] reset: accept "git reset HEAD " Jonathan Nieder
2010-10-19 23:08             ` Junio C Hamano
2010-10-19 23:26               ` Jonathan Nieder
2010-10-27 15:03     ` Git terminology: remote, add, track, stage, etc Ramkumar Ramachandra
2010-10-27 15:16       ` Drew Northup
2010-10-27 16:08         ` Matthieu Moy
2010-10-28 15:20           ` Ramkumar Ramachandra
2010-10-28 18:25             ` Matthieu Moy
2010-10-18 21:41 ` Matthieu Moy [this message]
2010-10-19  4:49   ` Miles Bader
2010-10-19  7:19     ` Wincent Colaiuta
2010-10-19  7:48       ` Miles Bader
2010-10-19  8:05         ` Wincent Colaiuta
2010-10-19 15:09           ` Eugene Sajine
2010-10-22 20:16             ` Paul Bolle
2010-10-22 21:00               ` Eugene Sajine
2010-10-22 21:46                 ` Drew Northup
2010-10-20  9:53   ` Thore Husfeldt
2010-10-20 11:34     ` Matthieu Moy
2010-10-20 14:01       ` Drew Northup
2010-10-18 21:57 ` Jakub Narebski
2010-10-19  8:05   ` Matthijs Kooijman
2010-10-19  8:27     ` Jakub Narebski
2010-10-19 17:30       ` Thore Husfeldt
2010-10-19 20:57         ` Jakub Narebski
2010-10-21  8:44   ` Michael Haggerty
2010-10-21 11:20     ` Drew Northup
2010-10-21 12:31       ` Thore Husfeldt
2010-10-21 12:56         ` Drew Northup
2010-10-21 14:06           ` Thore Husfeldt
2010-10-21 20:06             ` Drew Northup
2010-10-22  4:07       ` Miles Bader
2010-10-22 11:51         ` Drew Northup
2010-10-19 14:39 ` [PATCH v3] Porcelain scripts: Rewrite cryptic "needs update" error message Ramkumar Ramachandra
2010-10-27 14:55   ` Ramkumar Ramachandra
2010-11-05 22:38     ` Junio C Hamano
2011-02-12 23:14   ` Ævar Arnfjörð Bjarmason
2010-10-19 21:53 ` Git terminology: remote, add, track, stage, etc Drew Northup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpq8w1v5gce.fsf@bauges.imag.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=thore.husfeldt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).