Skip to content

Instantly share code, notes, and snippets.

@paulscott
Created November 7, 2018 23:28
Show Gist options
  • Save paulscott/0d4dd938e634a505bf1eb985e4b13020 to your computer and use it in GitHub Desktop.
Save paulscott/0d4dd938e634a505bf1eb985e4b13020 to your computer and use it in GitHub Desktop.
List the local and remote git branches and tags that contain a commit, branch, tag, or object
#!/bin/bash
if [ -z "$1" ]; then
echo 'usage: git contains <commit|object>'
exit 1
fi
if [ ! $(git rev-parse --is-inside-work-tree 2>/dev/null) ]; then
echo "fatal: Not a git repository"
exit 1
fi
echo branches:
git branch --all --contains "$1"
echo tags:
git tag --contains "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment