El 16/4/2008, a las 17:45, Garry Hill escribió: > > On 16 Apr 2008, at 16:35, Wincent Colaiuta wrote: > >> You can _stage_ individual hunks using: >> >> git add --interactive > > I've been trying to understand this stuff, the use of the index and > this idea of staging, but at the moment it's a bit much.
Well in this case it's quite easy. You have a bunch of changes in your working tree which really should be two separate commits. The index is a staging area where you prepare exactly what the commit is going to look like. You can either add entire files or use "git add -- interactive" to stage just hunks of files. When you finally do a "git commit" it is the state of the index which is used to create that commit; the state of the working tree has nothing to do with it at that point (unless you use "git commit -a", but then you're losing the benefit of the staging area). >> A different notion is that of "resetting", which involves going back >> to an earlier point in the history so that you can change the >> commit(s). See the "git-reset" man page for details on the different >> types of reset that you can do. For more complicated history >> manipulation their's "rebasing" (see the man page for "git-rebase", >> especially "git rebase --interactive"). > > I've been using 'git reset --soft HEAD~1' (say) which is cool. One > weird thing is that once you've done that 'git status' says there are > uncommitted changes, but 'git diff' shows nothing. Check out the "git-reset" man page. When you say --soft you are just moving HEAD back in time without touching either the working tree or the index. "git diff" will show nothing here because when no other parameters are passed it will show you the differences between the working tree and the index, and your "git reset --soft" touched neither of those. See the "git-diff" manpage for info on the other options; the most common combinations will be: # show differences between working tree and index # in other words, "what I could stage right now" git diff # show differences between index and head # in other words, "what I have staged already" git diff --cached # show differences between working tree and head # in other words, "both staged and unstaged changes" git diff HEAD I use these so often that I set up aliases for them so I can do "git staged", "git unstaged", "git both", although in reality the only ones I use with frequency are "git staged" and "git diff" (which is equivalent to "git unstaged" but shorter to type); I am seldom interested in "git both". > Cheers, Wincent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
