Last Updated on January 30, 2021 by sandeeppote
Before this if you want to see Git workflow/ three tree architecture
Stage changed files
To add the changes to the staging index from working directory use following command-
git add .
This will stage all changed files (.) in working directory
To add specific file to staging index-
git add filename.txt
Stage and commit at once
Per above this is 2 stage process to commit changes to repository. If you have all files that are ONLY modified use following command to directly commit from working repository. This command can also be used for renamed file.
git commit -am "provide a message here"
So no need to explicitly add to the staging index, instead the above command shall update repository.
Going back to committing changes, use following command-
git commit -m "message goes here"
Please note the best practice to put the message on what is this commit about and the message to be in the present tense.
git reset HEAD fiel.txt
If you put something in staging directory and don’t want there, then use reset head.