Last active
October 17, 2020 01:33
-
-
Save telmotrooper/2facfb5ab33fb501ce256f3ba3552f62 to your computer and use it in GitHub Desktop.
POSIX-compliant commands to automate common Git tasks
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
# Create a new branch based on the current one and push it to the remote. | |
function gcob { | |
echo "You're on branch \"$(git branch --show-current)\"." | |
git pull | |
echo "Creating branch with name \"$1\"." | |
git checkout -b $1 | |
echo "Pushing branch to remote." | |
git push --set-upstream origin $1 | |
} | |
# Delete a branch both on local and remote. | |
function gdel { | |
echo "Deleting branch \"$1\" both locally and remotely is a destructive operation." | |
echo -n "Do you want to proceed anyway? (y/N) " | |
read answer | |
if [ "$answer" != "${answer#[Yy]}" ] ;then | |
git branch -d $1 & git push origin --delete $1 | |
echo "Branch \"$1\" deleted." | |
else | |
echo "Operation aborted." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment