6
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.
6
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.
13
The command:
git commit -m "Teste"
Commit only the modified and added files in the area of Stage (Changes to be committed
) Git. That is, it’s just the files you added using a command like this:
git add nome_arquivo.txt
Or this:
git add .
Already the command:
git commit -am "Teste"
Do two things: add all modified files in the Stage and then commit them. In terms of the command, it’s the same that 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
4
Instead of you needing to make one git add <meu arquivo>
(which adds the file to carry out your commit) and then do a git commit -m <minha mensagem de commit>
(commits its change by assigning a message to it), the git commit -am <minha mensagem de commit>
already makes these two steps at once.
4
The git commit -m
sets only the commit of the modifications that are previously added to your tree, combining this with the option -m
, waiting for a message to bring your commit to life.
Using the -a
you beyond the commit and message, add all the files that are already trackeados by git, beware, as -a option does not add files created at the moment, only those that form modified or deleted. Thus, you can join the -a
with the -m
resulting in -am
saving you the time of git add <diretório(s) ou arquivo(s)>
Browser other questions tagged git terminal commit
You are not signed in. Login or sign up in order to post.
In general, on the
staging area
– Jefferson Quesado
So I don’t need to use the
git add ...
and I can only use the-am
? This will facilitate my process.– Henrique
@Henrique Depende. If you have any files that you don’t want to go to the next commit, you better do
add [arquivos que quero]
andcommit
(without the-a
) separately. But if you want everything to be committed, use-a
– hkotsubo
Yes, yes, thank you very much.
– Henrique