Committing Changes
Checking the Status
Before committing, it's always a good idea to check the status of your repository to see if there are any missing files and if everything is going the way you had planned.
Use the command git status
for this.
Adding files to the staging area
You can add multiple files to the staging area at a time, you can also add one file at a time.
Adding only one file to the staging area
This can be done when there is only one file to commit or if there are files you do not want to add.
Use this command to add one file to the staging area:
git add [file-name.txt]
Obviously, you'd use the correct file extension, and not just .txt
.
Adding all files to the staging area
If you just quickly want to add all files to the staging area, there is also a command for that. It is pretty convenient, especially if there are a lot of files you want to add to the staging area.
The command to add all files at once to your staging area is the following:
git add .
Committing the changes
Once all files have been added to the staging area, you can commit them. This can be done with the following command:
git commit -m "commit message"
It's a good idea to add a commit message to be able to find your commit back if needed.
Removing a file or folder
There are always reasons why you'd want to remove a file or folder. Use the following command when you need it.
git rm -r [file-name.txt]