• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

Git Commit History

Thumbnail for Glory KimGlory Kim

Glory Kim

Software Engineer, Loom

Published: 12/1/2023

About Terminus

Viewing a single git commit’s history

The git show command is used to view the changes of a specific commit:

 git show <commit-hash>

Run in Warp

For example, I can type git show 0f8497 to see the log message and the changes that occurred in this specific commit. On the left, we have the command and the right pane is the result with the diff.

Thumbnail for

Show the last git commits

To see the changes made in the last commit without using a hash, you can use the git show HEAD command. The HEAD here refers to the most recent commit within the git history of the project.war. You can use HEAD~1 to go back an extra commit, HEAD~2 to go back two, etc.

Viewing a git branch’s entire history

Each branch has a commit history. To list commits as a view of a branch's history, you can use the git log command with the branch name.

  • git log: shows the commit history for the branch currently checked out. If you have not checked out a branch, this will show you the commit history of the entire repository.
  • git log <branch-name>: shows the commit history for the specified branch and any commits shared by it's parent branches
  • git log <file-path>: shows the commit history of the file path

As a developer working at a fast paced startup, I like to use git log -n --oneline to view a summary of the last n commits in one-liners.

Thumbnail for

The screenshot above compares just running git log vs git log -4 --oneline.

Using GitHub to show commit history

To view the commit history of a repository on Github, you can click on  the “Commits” button on the homepage of the project. This re-routes to a URL of the form https://github.com/company\-name/repository\-name/commits/main  and shows a list of the commits made to the project with full detail. Below is a screenshot of the React library’s most recent commits.

Thumbnail for

Use git reflog to recover lost commits

There may be instances when you use git log but the commit you are searching for is not showing up. With Git, it's possible to lose a commit by accidentally using commands like git reset --hard or through Git's garbage collection which removes unreferenced objects from the repository. These commits may not show up when calling git log, but you may be able to recover it using git reflog.

Unlike git log, git reflog is a local recording of changes made and tracks commits across every branch. By default, this tool keeps the record for 90 days and lets you return to old commits not referenced by any branches.

Use AI to recall these various git commit history commands

If you’re using Warp as your terminal, you can use Warp’s AI Command Search feature to surface the various commands to check history discussed above.

The easiest way to do this is to trigger the feature with #, and type what you are looking for, such as:

 $ # show lost commits

Run in Warp

Thumbnail for

Written by

Thumbnail for Glory KimGlory Kim

Glory Kim

Software Engineer, Loom

Filed Under

Related Articles

Undo A Git Pull

How to effectively remove the commits introduced by a pull in Git using git-reset and preserve your local changes using git-stash. Also, how to cancel an unmerged pull request on GitHub.

Git
Thumbnail for Glory KimGlory Kim

Undo a Git Merge

How to rollback the changes introduced by a merge in Git by adding new opposite commits using git-revert and effectively removing commits using git-reset.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Prompt Show Git Branch In Prompt

Enhance your terminal with a custom Git prompt. Learn different ways to integrate this contextual info, from custom shell functions to Warp context chips and toolkits like Starship and P10K.

Git
Thumbnail for Gabriel ManricksGabriel Manricks

How To Remove Secrets From The Git History Remove Secrets From The Git History

Learn how to remove secrets from the Git history using the BFG and git-filter-repo command-line tools.

Git
Thumbnail for Utsav PoudelUtsav Poudel

Adding a Submodule in Git

This post will show you how to simply add a submodule to a local repository, clone a repository with a submodule, and work within a repository that has a submodule.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undo a git push

This post will show you had to simply undo a git push three different ways.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undo Git Add

Learn how to effectively use 'git add' to stage files in Git for committing, and discover two powerful methods to undo accidental stagings.

Git
Thumbnail for Glory KimGlory Kim

Undo a Git Rebase

This post will show you how to undo a rebase using git reset, git rebase and git revert

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Git Push Origin

A breakdown of git push origin

Git
Thumbnail for Amanda KhooAmanda Khoo

Create Folder In GitHub Repository

Learn how to create and push one or more empty directories in a Git repository using `.placeholder` and `README.md` files using both the CLI and the GitHub interface.

Git
Thumbnail for Razvan LudosanuRazvan Ludosanu

Git Push Tags

This post will show you how to push a single tag, multiple tags, all tags, and tags with commits.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undoing Git Commits

Explore ways to undo a commit, including git reset, git checkout, and git revert with git while preserving commit history.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Thumbnail for null