Important Commands
git reflog
The git reflog
command allows you to display all the commits that the head (HEAD) has gone through, in reverse chronological order. This allows you to revert to a previous state if you made a mistake in an operation.
git reset
The git reset <sha1-or-ref>
command allows you to reset the current branch to a particular commit (or ref):
shell
git reset 123abcd3 # 123abcd3 is the SHA-1 of a commit
shell
git reset develop # develop is the name of a branch
git restore
The git restore
command allows you to move one or more files and/or folders from one state to another:
The following command will move index.html
from a modified state (compared to the previous commit) to an unmodified state (the same state as in the previous commit):
shell
git restore index.html
The following command will move index.html
from a modified and staged state (compared to the previous commit) to a modified but unstaged state:
shell
git restore --staged index.html