Skip to main content

Hi, I'm Mike! I'm a web nut and Drupal expert at Phase2.

I also do Drupal site audits and Drupal consulting on the side. Shoot me an email!

A collection random useful Git snippets

This is the post that I'll use as a living dumping ground for random useful git snippets that I come across. Enjoy!

Use git blame to see when a change was REALLY made, as opposed to just a whitespace or copy/paste commit:

Fetch a file from another branch without switching branches:

Delete already-merged git branches (except for specific ones you name):

View the git log for a specific line or number of lines in a file:

Search all commit diffs for a specific string - both regex and non-regex versions

View a diff on a specific file between the current branch and another branch

Move your last commit to a different branch, for when you accidentally commit to the wrong branch

Delete all untracked files, but do a dry run first:

List the most recently updated branches: