Last active
August 29, 2015 14:02
-
-
Save jasonseney/778c3e842ee372a4af00 to your computer and use it in GitHub Desktop.
Quickly jump to a remote branch and sync. Usage: `git review some-branch-name`
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
#!/usr/bin/env bash | |
# Checks out to headless state of a remote branch and syncs | |
# Usage: `git review some-branch-name` | |
red='\033[31m' | |
green='\033[32m' | |
NC='\033[0m' # No Color | |
echo -e "${green}Stashing current changes...${NC}"; | |
git stash; | |
if [ $? -ne 0 ] | |
then | |
echo -e "${red}*** Stash FAILED ***${NC}"; | |
exit 1; | |
else | |
echo -e "${green}Fetching latest from server...${NC}"; | |
git fetch; | |
fi | |
if [ $? -ne 0 ] | |
then | |
echo -e "${red}*** Fetch FAILED ***${NC}"; | |
exit 1; | |
else | |
echo -e "${green}Checking out origin/$1...${NC}"; | |
git checkout origin/$1; | |
fi | |
if [ $? -ne 0 ] | |
then | |
echo -e "${red}*** Checkout FAILED ***${NC}"; | |
exit 1; | |
else | |
echo -e "${green}Syncing...${NC}"; | |
git-rsync; #Custom command to sync changes to a dev server | |
fi | |
if [ $? -ne 0 ] | |
then | |
echo -e "${red}*** Sync FAILED ***${NC}"; | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment