Understanding when to use git commit -m and git commit -am

My main question here is whether it makes sense to always do git commit -aminstead git add. and then git commit -m?

I understand that -am indicates that it will add all the changes from the modified TRACKED files. Therefore, in a situation where I did not add any new files, it would be advisable to simply run git commit -am instead of git add, but it would be best to do this:

git add.

git commit -am "message"

anyway?

or even instead:

git add -A

git commit -am "message"
+4
source share
3 answers

it would be best to use:

git add.

git commit -am "message"

anyway?

, " " . - , git add + git commit -m git commit -am .

, git add:

  • ,

, , , commit -a: , (, , - , ...). commit -a - git add.

, , , git commit -a.

+6

, -am, . git add -u , git commit -a, git diff --cached, , . , git add -p, , .

, , - git commit -am , , , .

+3

.gitignore , git commit -am - -. git add -uA <nopattern> ; git commit -m "message".

This is git, best practice is subjective. I prefer to add files manually to be able to view the changes as I go, but you may not need it.

+3
source

Source: https://habr.com/ru/post/1527582/


All Articles