How To Revert the Last git Commit

Author: , July 9th, 2020

shell$ git log | head -1 commit a203e1bd04718bff10a3df4a3389c493c97c0432 Use the commit string as the last argument to the git revert command: shell$ git revert -m 1 a203e1bd04718bff10a3df4a3389c493c97c0432

How To Find All git Commits Containing a Specific Log Message

Author: , July 9th, 2020

Show commits and messages that match

Include code diffs

Include file names

How To Find a Git Commit ID in Branches and Merges

Author: , February 7th, 2020

First, get on the branch that you know already has the commits you are looking for:

Copy-and-paste the commit(s) you want:

~or~

Optionally, display the code changes for a visual confirmation:

Finally, extract the list of branches that contain the desired commits:

Example:

How To Remove A File From The git Staging Pre-Commit List

Author: , May 31st, 2019

Quickref: How to Remove a file from the staging area

The Story Recently, I accidentally added some files to git’s pre-commit phase, i.e.:

For example, here is how to handle the above situation:

To better understand, here are the phases/states/stages that git uses: Untracked – when a file is first created, git […]

How To Revert a Single File to a Specific Commit Using git

Author: , March 18th, 2019

~or~