Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-15

Re: Why doesn't git commit -a track new files

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:39

Marco [off-list ref] writes:
I'm new to git and a bit confused about how some commands work.

git add .                    -- Adds everything *but* deleted files
git add -A                   -- Adds everything
git commit -a -m "whatever"  -- Commits everything *but* new files

I don't understand why there's not switch (is there?) for commit to commit new
and deleted files, like -A for git add?
Historical accident.  In the early days of git, there was no .gitignore
mechanism, so a mode that operates on everything under the working tree
was almost always an undesired thing to have (think *.o files).

Then .gitignore mechanism came, and "add ." has become usable.  But
"commit -a" has been widely used way before that.

If you look at "commit -a" within that context, you would understand why
it should only look at the paths git knows about.

Of course, "add -A" is a much later invention.  The option was named "-A"
with capital letter, even though there is no "add -a".

This was because I knew we would eventually want to have "commit -A" that
grabs everything and new files (honoring the gitignore mechanism), and
aimed for consistency between "add -A" that I was adding, and "commit -A"
that was yet to be written.  See 3ba1f11 (git-add --all: add all files,
2008-07-19).

I think it now is sensible to add "commit -A" if somebody is inclined to
do so.  Nobody felt the need for it strongly enough to do so, it seems.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help