Difference from: "git commit-am" and " - m"
What would be the difference between typing: git commit -m "Teste"
and git commit -am "Teste"
?
I'm learning about Git and would like to know how to differentiate this.
3 answers
The command:
git commit -m "Teste"
Commits only the modified files that are added in the stage area (Changes to be committed
) Git. That is, it is only the files that you added using a command like this:
git add nome_arquivo.txt
Or this:
git add .
Already the command:
git commit -am "Teste"
Does two things: adds all the modified files in the stage area and then commits them. In terms of command, it is the same as you do these two commands below:
git add . # adiciona todos os arquivos modificados no stage
git commit -m "Teste" # faz o commit dos arquivos modificados
Instead of you having to make a git add <meu arquivo>
(which adds the file to make your commit) and then make a git commit -m <minha mensagem de commit>
(which commits your change by assigning a message to it), git commit -am <minha mensagem de commit>
already does these two steps at once.
The git commit -m
defines only the commit of the modifications that are previously added in your tree, combining this option -m
, which waits for a message to bring your commit to life.
Using -a
you in addition to commit and message, add all files that are already tracked by git , Be careful, because the-A option does not add files created at the moment, only those that form modified or deleted. Thus, you can join -a
with -m
resulting in -am
saving time to perform git add <diretório(s) ou arquivo(s)>