Powerful git Commands (updated 2/11)

Photo by JJ Ying via Unsplash (cropped & edited)

Pickaxe (with & without specified file)

Search diffs for a particular string.

Purpose: If you’re trying to figure out when a particular line was changed and by who.

Across all diffs

git log -S your-string 

In a Specific File

git log -S your-string --path/to/your/file


More Documentation on git log


Purpose: When you’re trying to identify branches that can be deleted.

git branch --merged master

(Change “master” to branch of your choice.)



Purpose: When files are being ignored but you are having difficulties determining which line in .gitignore is causing it.

git check-ignore –n –v path/to/your/ignored/file

My post


Updating a Commit Message – rebase & reword

git rebase -i HEAD~1

(Change “1” to the number of previous commits you want to review.)

Follow the on-screen prompts to reword.


Undo Unpushed Commits

Purpose: When you committed something that you don’t want to push. Changes move from the local, unpushed commit to unstaged changes.

Examples: Mistake commits; also for if you use a GUI and merged a branch in that needs further edits, or if you want to revert only part of a commit but not all of it.

git reset HEAD~