[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: VC mode and git

From: Yuri Khan
Subject: Re: VC mode and git
Date: Thu, 26 Mar 2015 00:37:06 +0600

On Thu, Mar 26, 2015 at 12:19 AM, Alan Mackenzie <address@hidden> wrote:

> I'm mystified as to what the git index is for.  What's its motivation,
> what's it used for, what does it gain me in exchange for the extra
> complexity?  Does anybody have a link to a justification?  I'm genuinely
> curious about this.

I view the index as a convenience.

The use case goes like this. I work on a feature. At the same time, I
notice some coding style violations, or bad spelling/grammar, or
possible enhancements unrelated to the feature.

Without using the index, I’d have to make a conscious effort to avoid
mixing feature-related work with all those other good and useful
modifications. Make notes on a piece of paper. Finish the feature
work, commit, then go over the notes, do a few more commits.

However, with the index, I can do all of these things as soon as I
feel the need. Then I call up the Magit status buffer which shows me
all unstaged changes. I go over them and stage only those that I want
to put in a single commit, e.g. all the spelling fixes. I make a
commit, then repeat with the reduced set of changes. With a single
key, I can stage all changes, or all changes to a single file, or an
individual hunk, or a selected region.

Occasionally, a line will be changed in two or more unrelated ways. At
this point, I have to go to the file buffer and temporarily edit the
line to have the form I want to commit. After staging, I undo the
change so the file in the working copy remains in its final form.

Bottom line: The index allows me to do several unrelated changes in
the working copy, then separate them in two or more commits.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]