Last active
July 6, 2021 22:49
-
-
Save jdmallen/3f73e5cd686e75b3290f4075a7a9d027 to your computer and use it in GitHub Desktop.
My complete .gitconfig file that I take everywhere I go. I included comments for all my aliases that aren't obvious.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [user] | |
| name = J.D. Mallen | |
| email = | |
| # uncomment the below to add a GPG signing key | |
| #signingkey = | |
| [core] | |
| askpass = git-gui--askpass | |
| autocrlf = true | |
| editor = vim | |
| pager = less -x1,3 | |
| [commit] | |
| # uncomment the below to sign all commits by default | |
| #gpgsign = true | |
| [push] | |
| default = simple | |
| [alias] | |
| # adds all files, including untracked, to the working tree | |
| a = add | |
| aa = add -A . | |
| # adds files while disregarding whitespace changes (handy when line endings | |
| # get changed) | |
| addnw = "!sh -c 'git diff -w --no-color \"$@\" | git apply --cache --ignore-whitespace' -" | |
| # alias inception-- an alias to create a new alias. usage printed with cmd. | |
| alias = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -" | |
| # applies a git command to all subdirectories that are git repos | |
| # e.g. assume you have ~/projects/repo1, ~/projects/repo2, you can run | |
| # `git all fetch` in ~/projects to run `git fetch on repo1 and repo2 | |
| all = "!f() { ls | xargs -I{} git -C {} $1; }; f" | |
| # add patch-- stage just parts of files | |
| ap = add -p | |
| # deletes uplinks to remote branches that have been deleted | |
| # and deletes local branches that have been merged other than | |
| # master and your current checked out branch | |
| bc = "!sh -c 'git fetch -p; for b in $(git branch --merged | grep -v \"*\" | grep -v master); do git branch -d $b; done'" | |
| br = branch | |
| branches = "!echo ' ------------------------------------------------------------' && git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads && echo ' ------------------------------------------------------------'" | |
| # automatically stage all modified files that are tracked (does not add new | |
| # files) and commit with a message in quotes, | |
| # e.g. `git ca "Fix bug in the place with the stuff"` | |
| ca = commit -am | |
| ci = commit | |
| cl = clone | |
| co = checkout | |
| cob = checkout -b | |
| # following unsuccessful merge, list files that have Unmerged changes; i.e., | |
| # files with merge conflicts | |
| conflicts = diff --name-only --diff-filter=U | |
| cp = cherry-pick | |
| # commit GPG-signed | |
| cs = commit -S | |
| # get diff of staged files, excluding minified files | |
| dc = "!sh -c 'git diff --ignore-space-at-eol --cached $1 \":(exclude)*.min.js\" \":(exclude)*.min.css\"'" | |
| # get diff of unstaged files, excluding minified files | |
| df = "!sh -c 'git diff --ignore-space-at-eol $1 \":(exclude)*.min.js\" \":(exclude)*.min.css\"'" | |
| # possibly my favorite: if you accidentally type git twice, e.g. | |
| # "git git push", the command you originally wanted will still work. | |
| # it cancels out subsequent "git"s | |
| git = !git | |
| # delete all changes made since the last commit. careful with this one! | |
| hard = reset --hard HEAD | |
| # extremely verbose git log. combination of `git show` for all commits, | |
| # along with the diff between that commit and the one prior. best used with | |
| # a specific commit hash, e.g. git lg 123abcd | |
| lg = log -p | |
| # list of commits, one line a piece. very easy to fetch a specific hash | |
| lp = log --oneline | |
| mg = merge | |
| # force a recursive merge, no fast-forwarding | |
| mn = merge --no-ff | |
| pl = pull | |
| ps = push | |
| pushup = push --set-upstream origin | |
| # ever try to push a branch for the first time and get that annoying message | |
| # to --set-upstream? this does it for you. | |
| pu = ![[ $(git config "branch.$(git symbolic-ref --short HEAD).merge") = '' ]] && git push --set-upstream origin $(git symbolic-ref --short HEAD) || git push | |
| ra = remote add | |
| rd = remote remove | |
| re = remote | |
| rs = remote set-url | |
| # list all remotes | |
| rv = remote -v | |
| # the best way to see the status: each file on one line, and one line to | |
| # show the relationship to remote branch | |
| st = status -sb | |
| # lists the contributers with how many commits each | |
| who = shortlog -s -- | |
| [http] | |
| sslVerify = true | |
| # uncomment the below to force git to use the Windows certificate store | |
| # (Windows only, obviously) | |
| #sslBackend = schannel | |
| # The rest is so I can use Beyond Compare 4 for fancy diffs/merges. | |
| # Delete if you don't use it. | |
| [diff] | |
| tool = bc | |
| [difftool] | |
| prompt = false | |
| bc = trustExitCode | |
| [merge] | |
| guitool = bc | |
| tool = bc | |
| [mergetool] | |
| bc = trustExitCode | |
| [difftool "bc"] | |
| path = c:/Program Files/Beyond Compare 4/bcomp.exe | |
| [mergetool "bc"] | |
| path = c:/Program Files/Beyond Compare 4/bcomp.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment