Answer the question
In order to leave comments, you need to log in
Git commit -a works weird?
Hi friends.
Such a problem .. I read that in order not to write before the commit every time git add . you can write the key -a during the commit, sort of like this:
But for some reason it works for me every other time. Either untracked files are added, or not. How to understand the logic why this happens? How do you commit? git commit -a -m 'Comment to commit'
Answer the question
In order to leave comments, you need to log in
Hello.
It's just that this shortcut is used in the case of an already existing file in which you make changes. Otherwise, at the very beginning, once you've created a new file , you need to add it in the usual way, via a series of separate add and commit . And after - you can use -a -m .
# создаем новый файл math.txt
echo "# Comment " > math.txt
git add math.txt
git commit -m "This is the first commit."
# Вносим изменения в уже существующий math.txt
echo "a=1" >> math.txt
git commit -a -m "This is the second commit."
If you have created a new file, you must add it to the repository at least once with git add.
git commit -a will commit all files that are already being tracked. In other words:
* New file - git add.
* Changed files - can be done automatically via git commit -a
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question