Skip to content

Instantly share code, notes, and snippets.

@maheshgawali
Last active December 21, 2017 04:47
Show Gist options
  • Save maheshgawali/872fa5a09fa5b0e2f872619a5bee9ef4 to your computer and use it in GitHub Desktop.
Save maheshgawali/872fa5a09fa5b0e2f872619a5bee9ef4 to your computer and use it in GitHub Desktop.
git command to find merged branch in order of last commit
#!/bin/bash
echo -n $'#####################################################\n'
echo -n $'### Find all git branches merged into this branch ###\n'
echo -n $'#####################################################\n'
response=
echo -n $'\nEnter name of the git branch > '
read response
if [ -n "$response" ]; then
git_branch=$response
fi
git for-each-ref --sort=-committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset)|%(contents:subject)|%(authorname)|%(color:green)%(committerdate:relative)%(color:reset)" --merged $git_branch --color=always | column -t -s "|"
# add more options to list all remote branches as well , also for showing / hiding commit messages
# show commit hash
#git for-each-ref --sort=-committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset)|%(color:red)%(objectname:short)%(color:reset)|%(contents:subject)|%(authorname)|%(color:green)%(committerdate:relative)%(color:reset)" --merged $git_branch --color=always | column -t -s "|"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment