Skip to content

Instantly share code, notes, and snippets.

@olix0r
Created January 17, 2017 21:49
Show Gist options
  • Save olix0r/1a5de27cd169586a098cb39e6b41cc84 to your computer and use it in GitHub Desktop.
Save olix0r/1a5de27cd169586a098cb39e6b41cc84 to your computer and use it in GitHub Desktop.
Questionable Git Aliases
#!/bin/sh
set -e
# When the current branch has been merged to the origin, update master
# and delete the local branch.
branch=$(git rev-parse --abbrev-ref HEAD)
if [ -z "$branch" ]; then
echo "Could not parse branch" >&2
exit 1
elif [ "$branch" = "master" ]; then
echo "Already on master" >&2
exit 2
else
echo ":; :; git co master"
git co master
echo ":; :; git pull origin master"
git pull origin master
echo ":; :; git branch -D $branch"
git branch -D "$branch"
echo ":; :; git remote prune origin"
git remote prune origin
fi
#!/bin/sh
set -e
base=${1:-master}
branch=$(git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/\* \(.*\)/\1/')
if [ -z "$branch" ]; then
echo "Could not parse branch" >&2
exit 1
else
if [ $branch != $base ]; then
echo ":; :; git co $base"
git co $base
fi
echo ":; :; git fetch origin $base"
git fetch origin $base
echo ":; :; git pull origin $base"
git pull origin $base
if [ $branch != $base ]; then
echo ":; :; git co $branch"
git co $branch
echo ":; :; git rebase -i $base"
git rebase -i $base
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment