Question

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"?

Was it helpful?

Solution

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".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top