This is my personal study note to review and remember learning Git.
Commands
git show HEAD: to see the HEAD commit. (the change I made.)
git checkout HEAD filename: to discard the change you made.
git add filename filename filename: to add files to staging area at once.
git add . : to add all the files in the working directory to staging area
git reset HEAD filename: to remove the file from the staging area.
git reset commit_SHA: to go back to where you made change. everything after there will not be shown anymore.
git revert HEAD filename: to show your changes from the original.
Relative Refs Commands (To move around branches)
git checkout branch_name^: to move upward one commit one at a time. if want to move upward two commits, use ^^, ^^^ for three commits
git checkout HEAD^ can be used also.
git checkout HEAD~4: to move HEAD 4 times upward of commits at one time.
git branch -f branch_name HEAD~4: to move (by force) the branch_name to 4 upwards(~4).
git branch -f branch_name commit_SHA: to move branch_name to commit_SHA location
I am studying these from the web https://www.codecademy.com/learn/learn-git with seven days free trial, and https://learngitbranching.js.org/ which is totally free to learn.