Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
Last active February 1, 2016 22:55
Show Gist options
  • Select an option

  • Save jeremybeavon/247e47a151d3b26d0b9d to your computer and use it in GitHub Desktop.

Select an option

Save jeremybeavon/247e47a151d3b26d0b9d to your computer and use it in GitHub Desktop.
Handy git commands
# Find number of commits
& git rev-list --all --count
# Find log details for a single commit
& git log -1 $gitHash
# Find log details from a commit
& git log $gitHash..HEAD
# Find log details from a commit including the commit
& git log $gitHash^^..HEAD
& git log $gitHash~..HEAD
# Find files in a commit
& git show --pretty="format:" --name-only $gitHash
# Find first commit in a repo
& git rev-list --max-parents=0 HEAD
# Find the commit attached to a tag
& git rev-list -1 $tagName
# Find all dangling commits
& git fsck --lost-found
# Delete all dangling commits
& git reflog expire --expire-unreachable=now --all
& git gc --prune=now
# Create a repository from a single directory (Copied from https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/)
& git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment