[Gllug] Mercurial or Subversion for single user?

Nix nix at esperi.org.uk
Wed Mar 24 00:44:08 UTC 2010


On 23 Mar 2010, Matthew King stated:
> git mv foo bar
>   Analog of mv foo bar
>
> git rm foo
>   Analog of, you guessed it, rm foo
>
> git add bar
>   Opposite of git rm

No! No! No! It's not the opposite at *all*, and getting this wrong leads
to great confusion down the road.

It adds *the actual file*, i.e. the *actual content* to the 'index'
(also known as the 'cache' or 'staging area', which is a sort of limbo
files go into before commit. Change the file after 'git add' then do a
'git commit', and the thing you added, *without that change*, is what
gets committed, because what gets added is what's in the index, and the
index hasn't changed since you did a 'git add'.

'git commit -a' is the same as 'git add .' (which adds everything in the
working tree which is in a file that git already knows about) followed
by 'git commit'.

The opposite of 'git add foo.c' is 'git reset -- foo.c'.

I find this really useful. I can do lots of work in a big change, then
split it into commits via a bunch of 'git add's followed by 'git
commit's: and if I later decide they're in the wrong order or some are
just wrong, I can use 'git commit --amend' and 'git rebase -i' to
reshuffle and tweak them to my heart's content.

(If the changes touch some of the same files, this won't work quite so
easily, but 'git add -p' lets you add only *chunks* of changed files,
similar to darcs.)

> Then there's branches, rollbacks, partial commits, etc. Still simple but
> by no means essential. gitk is also an immeasurably useful tool to
> provides a visual indication of your repository's history.

Yes indeed. (Though I'm not sure what rollbacks are, I don't think the
git docs use the term. Do you mean 'git commit --amend', or detached
heads?)

(and yes, 'detached HEAD' *is* the single silliest name for an obvious
concept in the entirety of the version control world.)
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list