Created
February 9, 2015 15:12
-
-
Save mikemclin/116afef8628c2f2cba91 to your computer and use it in GitHub Desktop.
Store Git branch name into variable
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
# Store the current Git branch | |
branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
branch_name=${branch_name:-HEAD} | |
# Do something | |
git checkout master | |
git merge $branch_name | |
git checkout $branch_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment