Git Command Reminders

Git Add

After finishing new changes or edits in a project, include them in your Git version control by using the following command:

$ git add .

The . will add ALL files that have been changed. If, for example, you want to only add the changes to one file, you can do git add [filename] instead.

Git Commit

To commit the changes to your repository (basically this means you are confirming that you want to keep the changes), you run the following the command:

$ git commit -m "A BRIEF MESSAGE ABOUT THE CHANGES"

Git Commit

Once the changes are committed, to push the new code to your Github repository use the following command:

$ git push

Discard changes in tracked files

$ git checkout -- .

Remove untracked files

$ git clean -f

Remove untracked directories

$ git clean -fd

Delete last commit but keep changes in working directory

$ git reset --soft HEAD~1

Delete last commit and discard changes

$ git reset --hard HEAD~1