Created
April 27, 2021 06:28
-
-
Save hbeni/16ffe4bfdfc31ce7d1fbe850e4510c3f to your computer and use it in GitHub Desktop.
GIT command: show branches the current branch contains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Show which branches the current branch contains | |
# | |
current_branch=$(git branch |grep ^* |sed 's/^[*]*\s*//') | |
branches_file=$(mktemp) | |
git branch |sed 's/^[*]*\s*//' > $branches_file | |
while read branch; do | |
branch_file=$(mktemp) | |
git branch --contains $branch > $branch_file | |
grep -q "$current_branch" $branch_file | |
[ $? -eq 0 ] && echo $branch | |
rm $branch_file | |
done < $branches_file | |
rm $branches_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment