Last active
January 27, 2021 08:02
-
-
Save devxoul/a972ba0db2a25b989887 to your computer and use it in GitHub Desktop.
Git Push Me: Git push current branch to origin.
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 | |
# https://gist.githubusercontent.com/devxoul/a972ba0db2a25b989887/raw/f62353501becb274eb63c76b83fbcc01250a286d/git-pushme | |
# git push origin CURRENT_BRANCH | |
BRANCH=$(git branch --list | awk '{ if ($1 == "*") print $2 }') | |
while true; do | |
read -p "Push branch '$BRANCH' to origin? [Y/n] " -n 1 -r | |
echo | |
if [[ ${#REPLY} > 0 && $REPLY =~ ^[Nn]$ ]] | |
then | |
echo "Abort." | |
exit 1 | |
fi | |
if [[ ${#REPLY} == 0 || $REPLY =~ ^[Yy]$ ]] | |
then | |
COMMAND="git push -u origin $BRANCH ${*:1}" | |
echo -e "Executing command '$COMMAND'" | |
$COMMAND | |
exit 0 | |
fi | |
echo "Enter 'y' or 'n'." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage