From: Junio C Hamano <junkio@cox.net>
To: linux@horizon.com
Cc: git@vger.kernel.org
Subject: Re: as promised, docs: git for the confused
Date: Sat, 10 Dec 2005 00:00:40 -0800 [thread overview]
Message-ID: <7v7jadwfdj.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20051209054401.4016.qmail@science.horizon.com> (linux@horizon.com's message of "9 Dec 2005 00:44:01 -0500")
linux@horizon.com writes:
> Like other version control systems, git has a current version (referred
> to as HEAD) in its object database, you make changes in the working
> directory, and then commit them, which appends a new version and makes
> that the new HEAD.
>
> However, there's also this "index" thing interposed. As "man git"
> explains, you can have one version of the file in the HEAD, a second
> in the index, and a third in the working directory. That's weird
> and confusing - why does git allow that? Why isn't the index just an
> implementation detail that caches the HEAD until you commit a new one?
>
> The answer is merging, which does all its work in the index. Being a
> toolkit, git has to pass partial merges around between its various
> tools, which means keeping track of multiple files all competing for
> the same name. Neither the object database nor the working directory
> let you have multiple files with the same name.
I do not necessarily agree with this claim that merging is the
whole story about index. As the steps in the hello/example
tutorial demonstrate, index is used to build up what you will
commit incrementally, and you can use this facility to view your
changes incrementally.
Your workflow could be like this:
$ git checkout
$ hack away
$ git diff ;# what have I done so far?
$ git diff HEAD ;# this one shows the same as the above.
$ git update-index frotz ;# now I am satisfied with my progress so far.
$ hack away further
$ git diff ;# what have I done since my last "satisfactory checkpoint"?
$ git diff HEAD ;# changes since the last commit -- this is
# different from the above, and gives a lot
# more output
$ git update-index nitfol ;# I am happy with what I've done
# to this file as well.
$ hack away further
$ git diff ;# changes since the checkpoint
$ git update-index frotz nitfol
$ git diff HEAD ;# final pre-commit review
$ git commit
You could view updating the index as "checking in" and making a
commit as "casting your cumulative check-ins in stone". You can
make "check in" as many times as you want, and there is "git
reset --mixed" to uncheckin the index changes. And by doing
intermediate "checkins" to index file, you can limit what "git
diff" shows only to changes since your last checkpoint, as
opposed to all the changes you have made since your last commit.
This is sometimes very useful, and I suspect your comment about
"commit -a will take care of everything, so you do not need to
know about update-index" is coming from your ignoring this
aspect of update-index.
next prev parent reply other threads:[~2005-12-10 8:00 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7vbqzrcmgr.fsf@assigned-by-dhcp.cox.net>
2005-12-09 5:43 ` as promised, docs: git for the confused linux
2005-12-09 9:43 ` Petr Baudis
2005-12-09 14:01 ` linux
2005-12-09 16:49 ` Randy.Dunlap
2005-12-09 19:12 ` Junio C Hamano
2005-12-09 21:54 ` linux
2005-12-09 23:23 ` Junio C Hamano
2005-12-12 16:34 ` Linus Torvalds
2005-12-12 17:53 ` Timo Hirvonen
2005-12-12 18:18 ` Linus Torvalds
2005-12-12 20:39 ` Randal L. Schwartz
2005-12-13 3:58 ` Joshua N Pritikin
2005-12-13 3:59 ` Randal L. Schwartz
2005-12-13 5:19 ` Junio C Hamano
2005-12-13 5:29 ` Linus Torvalds
2005-12-13 7:18 ` H. Peter Anvin
2005-12-13 8:01 ` Junio C Hamano
2005-12-13 13:58 ` Randal L. Schwartz
2005-12-13 21:16 ` Tip of the day: archaeology Junio C Hamano
2005-12-13 21:54 ` Linus Torvalds
2005-12-13 22:19 ` Junio C Hamano
2005-12-12 17:54 ` as promised, docs: git for the confused Junio C Hamano
2005-12-13 0:22 ` [PATCH] Everyday: some examples Junio C Hamano
2005-12-09 21:33 ` as promised, docs: git for the confused Petr Baudis
2005-12-09 5:44 ` linux
2005-12-10 1:22 ` Junio C Hamano
2005-12-10 8:00 ` Junio C Hamano [this message]
2005-12-10 10:56 ` linux
2005-12-04 21:34 git-name-rev off-by-one bug Petr Baudis
2005-12-08 6:34 ` as promised, docs: git for the confused linux
2005-12-08 21:53 ` Junio C Hamano
2005-12-08 22:02 ` H. Peter Anvin
2005-12-09 0:47 ` Alan Chandler
2005-12-09 1:45 ` Petr Baudis
2005-12-09 1:19 ` Josef Weidendorfer
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=7v7jadwfdj.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=linux@horizon.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).