Is it redundant to run git add .
and then git commit -am "commit message"
?
Can I just run git add .
and then git commit -m "commit message"
or, alternatively, just git commit -am "commit message"
?
As you're working, you change and save a file, or multiple files. Then, before you commit, you must git add . This step allows you to choose what you are going to commit.
First, you edit your files in the working directory. When you're ready to save a copy of the current state of the project, you stage changes with git add . After you're happy with the staged snapshot, you commit it to the project history with git commit .
Add and commit changesgit add : takes a modified file in your working directory and places the modified version in a staging area. git commit takes everything from the staging area and makes a permanent snapshot of the current state of your repository that is associated with a unique identifier.
Without adding any files, the command git commit won't work. Git only looks to the staging area to find out what to commit. Staging, or adding, files, is possible through the command line, and also possible with most Git interfaces like GitHub Desktop by selecting the lines or files that you'd like to stage.
Git add
+ git commit -m
will just commit those files you've added (new and previously tracked), but git commit -am
will commit all changes on tracked files, but it doesn't add new files.
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