Last active
December 25, 2017 13:38
-
-
Save hkraji/dee97cd38db70b85c54a5fd04bb47671 to your computer and use it in GitHub Desktop.
Bash script to update or checkout needed git branches
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# Usage: | |
# | |
# checkout BRANCH_NAME | |
# | |
# checkout master | |
# checkout hkraji/pr_work_in_progress | |
# | |
git rev-parse --verify $1 > /dev/null 2>&1 | |
if [ $? == 0 ] | |
then | |
echo "Branch $1 exists, updating branch ..." | |
git checkout $1 | |
git pull origin $1 | |
else | |
echo "Creating branch $1 ..." | |
git fetch origin $1 | |
git checkout -b $1 origin/$1 | |
fi | |
# clear nginx cache (optional) | |
rm -rf /tmp/nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment