Skip to content

Instantly share code, notes, and snippets.

@Bazsmagister
Last active July 14, 2024 08:49
Show Gist options
  • Save Bazsmagister/cb6c216c9053e2f798ca2ab8a2507db2 to your computer and use it in GitHub Desktop.
Save Bazsmagister/cb6c216c9053e2f798ca2ab8a2507db2 to your computer and use it in GitHub Desktop.
How to check last git commit?

How to see the last commit in git?

Sources:

https://stackoverflow.com/questions/2231546/git-see-my-last-commit

https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History

See my last commit in git:

//This command will display the commit hash, author, date, and commit message of the most recent commit in your repository.

git log -1

//to see the last 2 commits:

git log -2

//this show also the files

git log --name-status -1

oneliners:

git show --name-status --oneline

git show --name-status --oneline

a diff of your last commit:

git show

git log -1 --stat


It gives back only the file names, but now what happened to them.

git show --name-only

//If you have too many commits to review, this command will show them in a neat single line:

git log --pretty=oneline

//to see short, medium, full, or even more details of your commit, use following, respectively:

git log --pretty=short

git log --pretty=medium

git log --pretty=full

git log --pretty=fuller

//You can even use your own output format using the format option:

//where %an - author name, %ae - author email, %s - subject of commit, etc.

git log --pretty=format:"%an, %ae - %s"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment