Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.
git log -1 will display the latest commit message or git log -1 --oneline if you only want the sha1 and associated commit message to be displayed. Show activity on this post. git log -1 branch_name will show you the last message from the specified branch (i.e. not necessarily the branch you're currently on).
The git log command includes many options for displaying diffs with each commit. Two of the most common options are --stat and -p .
Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.
If you want to use the command line you can use the --author=<your name>
For example: to see your last 5 commits
git log -n 5 --author=Salvador
If you want a simpler one line solution:
git log --oneline -n 5 --author=Salvador
Edited to add
If you like the single line version, try creating an alias for git log
like this (this is what I have for zsh)
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Now, I can just use:
glog -n 5
And I get a nice output such as:
Which is colourised, shows the name of the author and also shows the graph and you can still pass in other flags (such as --author) which lets you filter it even more.
Use the --author
and/or --committer
filtering options with git log
, plus the -n
option to limit the number of commits. For example:
git log --author='Salvador Dali' -n 10
git log --format="%h %B" --oneline -n 1
This will get you latest git log comment block with abbreviated commit id.
git log --format="%H %B" -n 1
This will get you latest git log comment block with full commit id.
You can build your own format from : Git Pretty Format
git log --author="My name" -n 5
(see man git-log
for all alternatives)
See a list of comments of last N commits
git log --oneline -10
Check out to an older commit
git ckeckout 3e6bb80
Get back to the latest commit after checking out a previous commit
git checkout -
If you are after only the last X git commit messages, the following command will give you the last 5 commit messages as strings separated by new lines:
git log -5 --oneline --format=%s | sed 's/^.*: //'
will output something like this:
Remove references to Node 8
Move ESLint cache file into node_modules
Update postcss packages
Add TypeScript 4.x as peerDependency to react-scripts
Create FUNDING.yml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With