Skip to content

Instantly share code, notes, and snippets.

@UziTech
Last active March 16, 2021 15:42
Show Gist options
  • Save UziTech/c3c1e6415a53f14759afdc2bc582ec93 to your computer and use it in GitHub Desktop.
Save UziTech/c3c1e6415a53f14759afdc2bc582ec93 to your computer and use it in GitHub Desktop.
git aliases
[alias]
# rebase current branch with remote branch
# git up [remote=upstream] [branch=master]
up = !"f() {\
if [ $# -lt 1 ];\
then remote=upstream;\
else remote=$1;\
fi;\
if [ $# -lt 2 ];\
then repo=master;\
else repo=$2;\
fi;\
git fetch $remote &&\
git rebase $remote/$repo;\
}; f"
# rebase current branch with remote branch and force push
# git upf [remote=upstream] [branch=master]
upf = !"f() {\
git up $1 $2 &&\
git push -f;\
}; f"
# reset and rebase linked Atom package
# git atom/apm
atom = !"git apm"
apm = !"git upf upstream &&\
npm i &&\
apm rebuild &&\
git reset --hard"
# checkout or reset pr from remote
# git pr [remote] [pr #]
pr = !"f() {\
if [ $# -lt 2 ];\
then echo 'Error: Must provide a remote and pr #';\
exit 1;\
else git branch --delete --force pr/$2;\
git fetch $1 pull/$2/head:pr/$2 &&\
git checkout pr/$2;\
fi;\
}; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment