Created
March 31, 2015 10:22
-
-
Save dylansmith/0599351f9b4f6a044b44 to your computer and use it in GitHub Desktop.
A bash alias to push a local git branch for the first time with --set-upstream
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 | |
# place this in your .bash_aliases or similar | |
git_current_branch() { | |
git rev-parse --abbrev-ref HEAD | |
} | |
git_push_set_upstream() { | |
branch=`git_current_branch` | |
cmd="git push --set-upstream origin $branch" | |
echo "command: $cmd" | |
read -p "Are you sure (y/n)? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
eval $cmd | |
fi | |
} | |
alias gbc=git_current_branch | |
alias gpsu=git_push_set_upstream |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment