Skip to content

Instantly share code, notes, and snippets.

@mrduckieduck
Last active March 22, 2022 22:38
Show Gist options
  • Save mrduckieduck/fda9b30a9d16c01ad3d55e512142a82f to your computer and use it in GitHub Desktop.
Save mrduckieduck/fda9b30a9d16c01ad3d55e512142a82f to your computer and use it in GitHub Desktop.
My configuration for git, with all the useful alias
color]
ui = auto
[alias]
# short aliases
st = status
co = checkout
cob = checkout -b
ci = commit
cia = commit -a
br = branch
df = diff
lg = log -p
feo = fetch origin
cp = cherry-pick
me = config user.name
m = merge
ms = merge --squash
r = rebase
rc = rebase --continue
rs = rebase --skip
ra = rebase --abort
unstage = reset HEAD
# log aliases
log-branch = log origin/master..
blog = !git log-branch
mlog = !git log --committer=\"`git me`\"
rlog = !git log --reverse
# creates a diff of current branch against supplied branch, usage: git export-branch [refbranch]
branch-name = !git for-each-ref --format='%(refname:short)' `git symbolic-ref HEAD`
export-branch = !git format-patch --stdout $1 > ~/branches/`git branch-name`.diff
# all commits that aren't merges on all branches
all = !git log --pretty=oneline --abbrev-commit --all --no-merges
# all commits today for only me
today = !git all --since='12am' --committer=\"`git me`\"
plog = !sh -c 'git log | more'
# `git publish`
# current branch: push to a given remote server (or origin as default)
pub = "!f() { remote=${1-origin}; currentBranch=`git branch-name`; echo \"Pushing branch $currentBranch to $remote...\"; git push $remote $currentBranch; }; f"
# `git spawn my-new-branch`
# make new branch based on master no matter which branch is checked out
spawn = !sh -c 'git checkout -b $1 ${2-master} && git config branch.$1.localmerge ${2-master}' -
# `git hatch remote-branch-name`
# make new branch based on the remote branch passed
#hatch = !sh -c 'git checkout -b $1 origin/$1'
hatch = "!f() { remoteBranch=$1; git feo; git checkout -b $1 origin/$remoteBranch; }; f"
# `git nuke my-old-branch`
# (Checks out master and does a force delete on the branch entered)
nuke = !git co master && sh -c 'git br -D $1' -
# `git sync`
# update current branch with changes from a passed branch or master
sync = "!f() { git feo; git merge origin/${1-master}; }; f"
# `git rync`
# rebase current branch with changes from a passed branch or master
rync = "!f() { git feo; git rebase ${1-main}; }; f"
# `git squash`
# updates, using squash strategy, current branch with changes from a passed branch or master
squash = "!f() { git feo; git merge --squash origin/${1-master}; }; f"
# awesome placeholders
crunk = status
deploy = status
crazy = status
stupid = status
[init]
defaultBranch = main
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
@mrduckieduck
Copy link
Author

A no pos si funcionan los comentarios!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment