Skip to content

Instantly share code, notes, and snippets.

@EfrainReyes
Last active March 29, 2017 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EfrainReyes/d403a1a7f4256abac3a2 to your computer and use it in GitHub Desktop.
Save EfrainReyes/d403a1a7f4256abac3a2 to your computer and use it in GitHub Desktop.
my global git config
#[user]
# name = Your Name
# email = youremail@example.com
[core]
autocrlf = true
excludesfile = C:\\Users\\Efrain\\Documents\\gitignore_global.txt
editor = 'C:/Program Files/Sublime Text 3/subl.exe' -n -w
ignorecase = false
[push]
default = simple
[pull]
rebase = true
[grep]
# this assumes you either have Perl installed, or you have Git for Windows (which comes packaged with perl)
patternType = perl
[alias]
# from the Phil Haack blog post http://haacked.com/archive/2014/07/28/github-flow-aliases/
egc = config --global -e
elc = config --local -e
co = checkout
cob = checkout -b
br = branch
brd = branch -D
s = status -s
cm = !git add -A && git commit
amend = !git cm --amend
wip = !git cm -m "WIP"
up = !git pull --rebase --prune && git submodule update --init --recursive
undo = reset HEAD~1 --mixed
discard = !git cm -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# There are many places on the internet where you can get formatted log aliases. I took one and played around with the format until I got something I liked.
lg = log --oneline --pretty=format:'%C(bold red)%h %Creset%C(bold blue)[%an] %Creset- %s%C(bold cyan)%d %C(bold green)(%cr)%Creset' --abbrev-commit --date=relative
# From this blog post http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja/
search = grep --break --heading --line-number
# whenever there's an index.lock file that just won't go away
# shoutout to http://stackoverflow.com/a/28502292/2563028
removelock = "!f() { \
curr_dir=$(pwd); \
root_dir=$(git rev-parse --show-toplevel); \
cd $root_dir; \
rm -f ./.git/index.lock; \
echo 'Removed pesky index.lock file!'; \
cd $curr_dir; \
}; f"
# type "git i N" instead of "git rebase -i HEAD~$N" to rebase commits in your own branch (useful for squashing)
i = "!f() { git rebase -i HEAD~$1; }; f"
# Run cleaning and compression tasks on your repository, and get an output of the amount of bytes you're saving.
# Best used with git 2.11 or above
flush = "!f() { \
echo 'Please be patient! This operation may take a few minutes to run.'; \
curr_dir=$(pwd); \
root_dir=$(git rev-parse --show-toplevel); \
sed_expr=':a;s/\\B[0-9]\\{3\\}\\>/,&/;ta'; \
cd $root_dir; \
prev_size=$(du -bs . | tr -dc '0-9'); \
echo 'Current directory size:' $(echo $prev_size | sed $sed_expr) 'bytes.'; \
echo '--- Begin cleanup with aggressive optimization. ---'; \
git gc --aggressive --prune=now; \
echo '--- End repository cleanup tasks. ---'; \
new_size=$(du -bs . | tr -dc '0-9'); \
echo 'Cleanup complete. New size:' $(echo $new_size | sed $sed_expr) 'bytes.'; \
saved_bytes=$((prev_size - new_size)); \
echo 'Saved a total of' $(echo $saved_bytes | sed $sed_expr) 'bytes!'; \
cd $curr_dir; \
}; f"
[difftool "sourcetree"]
cmd = 'C:/Program Files/KDiff3/kdiff3.exe' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = 'C:/Program Files/KDiff3/kdiff3.exe' \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"
trustExitCode = true
[color]
ui = true
[branch]
autosetuprebase = always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment