Skip to content

Instantly share code, notes, and snippets.

@UziTech

UziTech/.gitconfig

Last active Mar 16, 2021
Embed
What would you like to do?
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