haziz
haziz

Reputation: 13592

Difference between ( git add -A followed by git commit ) and git commit -a?

git add --all or git add -A followed by git commit -m "commit message" seem to produce a different result from git commit -am "commit message" when I thought they would produce the same final result.

Am I doing something wrong with git commit -am "commit message"?

Also is git commit -a -m "commit message" the same as git commit -am "commit message"?

Upvotes: 2

Views: 686

Answers (1)

VonC
VonC

Reputation: 1323343

More generally, I always recommend to add first, check the status, and then commit.
I find that extra step a good opportunity to:

  • check that nothing had been forgotten for the next commit
  • check that no extra elements are added for the next commit (which shouldn't be part of it, being not ready)
  • polish the commit message (I usually git commit -f file)

And yes, git commit -a -m "commit message" is the same as git commit -am "commit message".

Upvotes: 4

Related Questions