Difference from: "git commit -am" and "-m"

3

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

    
asked by anonymous 21.11.2018 / 19:59

3 answers

9

The command:

git commit -m "Teste"

Commits only the modified files that are added in the stage area ( Changes to be committed ) of Git. That is, it's just the files you've added using a command like this:

git add nome_arquivo.txt

Or this:

git add .

Already the command:

git commit -am "Teste"

It does two things: it adds all the modified files in the stage area and then commits them. In terms of command, it's the same as you did these two commands below:

git add .               # adiciona todos os arquivos modificados no stage
git commit -m "Teste"   # faz o commit dos arquivos modificados
    
21.11.2018 / 20:19
4

Instead of having to make a git add <meu arquivo> (which adds the file to commit) and then make a git commit -m <minha mensagem de commit> (which commits its change by assigning a message to it), git commit -am <minha mensagem de commit> already does these two steps at a time.

    
21.11.2018 / 20:11
3

The git commit -m defines only the commit of changes that have been previously added to your tree, combining this option with -m , which expects a message to bring your commit to life.

By using -a , in addition to the commit and message, add all files that

21.11.2018 / 20:19