[plt-dev] git wackiness

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Apr 20 23:03:04 EDT 2010

On Apr 20, Jay McCarthy wrote:
> 
> I thought "git add" meant "reminder this file to include in the next
> commit". However, that's wrong:
> [...]

Executive summary:

  `svn commit'          ~  `git commit .'

  `svn commit path...'  ~  `git commit path...'


Yes, `git add' does not remember a file to include in the commit, but
the actual new contents to commit.  This is saved in something that is
known as "the staging area" or "the index".

It can be useful in some cases, but you can choose one of the
following ways to ignore it:

  git commit [path ...+]
    --> commits the given paths, regardless of that staging area (this
        is when at least one path is specified)

  git commit -a
    --> does a `git add' on all paths (`-a' stands for `all'), and
        then commits everything, so this is as if you run an `svn
        commit' on the repository root.

  git commit -i [path ...]
    --> does a `git add' on the listed paths, then commits them

If you never do an explicit `git add' yourself, then this staging area
is irrelevant -- the last two commands add stuff to it, but you won't
have other changes there.

But if you do have changes there, you can also do

  git commit -o [path ...]

which will commit *only* these paths, ignoring stuff that was added.
As the man page says, this is the default mode, which is why the first
option works.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.