Git
Add files to a commit
git add <FILES>
Use git mv
or git rm
for moved or deleted files.
Show the modified files
git status
Show the modifications in a file
git diff <FILE>
Commit
git commit -m "Description of the commit"
Fix last commit message
git commit --amend -m "Modified description"
Push commits
git push
Undo changes in a file
git checkout <FILE>
Get the list of commits
git log
Reverse a commit
git revert <SHA>
This does not delete the commit, it creates a new commit that cancels previous changes. The history is preserved.
git reset <SHA>
This deletes the not yet pushed commits from the history, but the files are preserved. The commits are deleted, but the contents are still on the disk.
To also cancel the changes on the contents:
git reset --hard <SHA>