Skip to content

Instantly share code, notes, and snippets.

@Gopikrishna19

Gopikrishna19/.gitconfig

Last active Nov 11, 2020
Embed
What would you like to do?
git config
[alias]
a = !git add . && git status
ac = !git a && git commit
c = commit
ca = commit --amend
cm = commit -m
co = checkout
cob = checkout -b
cp = cherry-pick
d = diff
l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
ll = log --pretty=oneline --abbrev-commit --decorate --simplify-merges --first-parent
llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
pr = !f(){ git fetch -fu ${2:-$(git remote | grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f
prc = !git co master -f && git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done
rh = "!f() { \
if [ $1 ]; then \
echo Resetting HEAD hard by $1...; \
git reset --hard HEAD~$1; \
else \
echo Resetting...; \
git reset --hard; \
fi \
}; f"
rs = "!f() { \
if [ $1 ]; then \
echo Resetting HEAD soft by $1...; \
git reset --soft HEAD~$1; \
else \
echo Unstaging...; \
git reset; \
fi \
}; f"
s = status
sync = !git remote | xargs -I % sh -c 'echo fetching % ...; git fetch %; echo pruning % ...; git remote prune %'
xm = !git add . && git status && git commit --amend --no-edit
[alias]
a = add .
s = status
cm = commit -m
co = checkout
cob = checkout -b
cp = cherry-pick
ll = log --pretty=oneline --abbrev-commit --decorate --simplify-merges --first-parent
nb = "!f() { git stash; git xprune; git xupdate; git cob $1; git stash pop; }; f"
nb-safe = "!f() { git stash; git co master; git xupdate; git cob $1; git stash apply; }; f"
nb-clean = !git xprune && git xupdate && git cob
pr = "!f(){ git fetch -fu ${2:-$(git remote | grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
prc = "!git co master -f && git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref; do branch=${ref#refs/heads/}; git branch -D $branch; done"
sync = !git remote | xargs -I % "sh -c 'echo fetching % ...; git fetch %; echo pruning % ...; git remote prune %'"
rh = "!f() { \
if [ $1 ]; then \
echo "Resetting HEAD hard by $1..."; \
git reset --hard HEAD~$1; \
else \
echo "Resetting..."; \
git reset --hard; \
fi \
}; f"
rs = "!f() { \
if [ $1 ]; then \
echo "Resetting HEAD soft by $1..."; \
git reset --soft HEAD~$1; \
else \
echo "Unstaging..."; \
git reset; \
fi \
}; f"
xprune = "!f() { \
git checkout master -f; \
git branch | grep -v '*' | xargs git branch -D; \
if [ $1 ]; then git xupdate; fi; \
}; f"
xremote = "!f() { \
echo Removing existing remotes...; \
git remote remove upstream; \
git remote remove origin; \
upstream=git@github.deere.com:$1/${PWD##*/}.git; \
origin=git@github.deere.com:gs89621/${PWD##*/}.git; \
echo Adding upstream: ${upstream}; \
git remote add upstream ${upstream}; \
echo Adding origin: ${origin}; \
git remote add origin ${origin}; \
git co master; \
git sync; \
git branch master --set-upstream-to=upstream/master; \
git xupdate; \
}; f"
xupdate = !git pull upstream && git push origin
xradd = "!f() { \
git remote remove $1; \
git remote add $1 git@github.deere.com:$1/${PWD##*/}.git; \
git fetch $1; \
}; f"
xrremove = "!f() { \
git remote remove $1; \
git remote -v; \
}; f"
xrprune = "!f() { \
git remote | grep -vE 'origin|upstream' | xargs git xrremove; \
git sync; \
}; f"
xm = !git add . && git status && git commit --amend --no-edit
xpush = !git push ${1:-origin} $(git branch --show-current) -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment