Skip to content

Git Command Collection

Git Command Collection published on

Overview

This page should be a collection of useful git commands I usually forget about

Commands

Find branches ordered by last commit date

git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'

https://stackoverflow.com/a/16961359/7311363

Delete local branches

# Remove information on branches that were deleted on origin (https://stackoverflow.com/a/5751635/7311363)

git fetch --prune

# or according to https://stackoverflow.com/a/8766540/7311363

git remote prune origin

# remove local branches that are not longer relevant according to https://stackoverflow.com/a/18380712/7311363

git branch --merged origin/master | xargs git branch -d
Categories