I noticed that git allows to commit a tracked file (which was modified locally) directly without using staging, eg:
$ git status -s .
M myfile.txt
$ git commit myfile.txt -m"1 way"
Is it better to use, instead, the "classic" two steps ? :
$ git add myfile.txt
$ git commit myfile.txt -m"2 way"
Try git commit -a -m [message]
-a
Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
Doesn't work for new files, you still need to explicitly add them.
It's just stage followed by commit in a single step. I find this convenient since one can see all changed states when using status and we typically make small incremental commits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With