Advanced Git Commands
Last updated
Last updated
Sample output of git log. Use j
and k
on the keyboard to scroll up and down and q
to exit the log view.
Each log entry will describe what that commit does. Each commit will have a commit hash, author and date.
For example this commit:
commit hash is f5458f36c67c927fcd41e65e29eb5b8a1491d7a1
author is francisyzy <francisyzy@me.com>
which was set by the author's git config
date of the commit is Fri May 17 17:14:09 2024 +0800
message of the commit is Update links
Lets you 'undo' a commit. It will undo the changes made by that commit and make a new commit to do so.
Do note that this is not the method of removing sensitive information as commit history can still retrieve it.
This will reset the current HEAD to the commit hash.
Useful reset command that can be used to edit the commit message before its being pushed to the remote is: git reset --soft HEAD~
. The command will reset the files to the commit right before the current commit and leave the files in the latest commit in staged. Allowing you to git commit -m "Updated message"
to change the git commit message.
You can also use git checkout <commit hash>
to go to view the files at a specific commit too.
A useful feature to have when you want to check out the files of that commit before you reset to that commit.
The git commit history is also viewable on the itself.
There is a on how to remove such information and rewrite history. Do note that rewriting history will result in other people's repo being broken.