On Wed, 5 Mar 2014 19:55:04 -0800 (PST)
dexter ietf <dexter.i...@gmail.com> wrote:

> what it means to git when i try to commit on the local folder.
> for example "git commit ." is there any real use case for this ?

Depends on how you're looking at it.  A commit in Git is a snapshot of
the whole repository so it doesn't matter where in the tree did you run
`git commit`.

The tricky part, however, is that "." argument in your example.
`git commit` accepts pathnames, and if they are specified, they
substantially change its behaviour: normally `git commit` records the
new commit based on the *staged* changes: changes added to the staging
area (also "the index") by means of the `git add` command; specifying
pathnames make `git commit` ignore these changes completely and record
the new commit using the current (as in the work tree) state of the
files passed to `git commit`.  In your example `git commit` will
supposedly pick all the tracked files in the current directory and use
their content to create a new commit; if there are modified files in
other directories in the work tree (no matter whether staged or not),
they will be ignored.

So, yes, in a sense, running `git commit .` in a subdirectory of the
work tree is like committing only the changes in that directory, but
you should clearly understand that this is vastly different from
Subversion where committing a subdirectory actually performs a
kind of server-side merge -- such a commit will succeed if there's no
changed files in that subdirectory made after our base revision.
In Git, the resulting commit will be the whole state of the project, as

Hence, as I've said, whether `git commit .` is a real use case or not
depends on your preference.  I, for one, do not like such shortcuts and
prefer to explicitly `git add` what I need, even if these changes are
localized to a subdirectory, review what I'm about to commit
(using `git diff --staged`) and then commit.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to