# See more: https://git-scm.com/docs/git-config # general config [user] name = Nick Plekhanov email = nicksp@users.noreply.github.com signingKey = 77258BB2E99B579D [github] user = nicksp [init] defaultBranch = main [apply] # Detect whitespace errors when applying a patch whitespace = fix [rerere] # Remember how you resolved a merge conflict and automatically reapply if it sees it again enabled = true [transfer] # Avoid data corruption fsckobjects = true [core] editor = cot --wait pager = hunk pager autocrlf = input safecrlf = false excludesFile = ~/.gitignore quotePath = false # Make `git rebase` safer on macOS # More info: https://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ trustctime = false # Uses a background process to watch for file changes, making commands like 'git status' nearly instantaneous fsmonitor = true # Speeds up how Git finds new, untracked files untrackedCache = true [help] # Correct typos autoCorrect = 1 [color] # Use colors in Git commands that are capable of colored output when # outputting to the terminal. (This is the default since Git 1.8.4) ui = auto [color "branch"] current = cyan bold reverse local = white plain = remote = cyan [color "status"] added = green changed = blue header = localBranch = nobranch = remoteBranch = cyan bold unmerged = yellow bold reverse untracked = black updated = blue [color "diff"] meta = black frag = black old = red new = green [column] # Put any list output into columns ui = auto [feature] # Enable optimizations for repos with many files manyFiles = true [filter "lfs"] clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process required = true # Any GitHub repo with my username should be checked out r/w by default # http://rentzsch.tumblr.com/post/564806957/public-but-hackable-git-submodules [url "git@github.com:nicksp/"] insteadOf = "git://github.com/nicksp/" # When accidentally cloning the HTTPS version of a repository instead of the SSH version [url "git@github.com:nicksp/"] insteadOf = "https://github.com/nicksp/" [protocol "file"] # Always permit operations using file protocol without any restrictions or warnings allow = always # command-specific [commit] # Include the diff of the changes at the bottom of the commit message template verbose = true # Custom template for new commit messages template = ~/.gitmessage # Sign all commits by default gpgSign = true [tag] # Sign all tags by default gpgSign = true [log] # Show branch names with git log decorate = short # Display dates as '2023-05-25 13:54:51' instead of 'Thu May 25 13:54:51 2023' date = iso [branch] # Show most recently changed branches first sort = -committerdate [fetch] # Automatically prune deleted branches and tags from your local copy # when you fetch (or pull) prune = true pruneTags = true # Cache the index of all the commit objects to speed up some Git commands writeCommitGraph = true [pull] # Rebase branches on top of the fetched branch, instead of merging # the default branch from the default remote rebase = true [push] # When pushing code, always push only your current branch to a branch # of the same name on the receiving end # http://stackoverflow.com/a/23918418/89484 default = current # Automatically set up upstream tracking # when no upstream tracking exists for the current branch autoSetupRemote = true # Make `git push` automatically push relevant annotated tags when pushing branches out followTags = true # Make `push --force-with-lease` even safer by ensuring the tip of the remote # was actually pulled into your local branch at some point useForceIfIncludes = true [rebase] # Automatically include the `--autosquash` option when doing a `git rebase --interactive` # See more: https://thoughtbot.com/blog/autosquashing-git-commits autoSquash = true # Auto-update dependent branches during rebase updateRefs = true # Automatically stash uncommitted changes before rebasing and re-apply them after — no more 'cannot rebase with dirty tree' errors autoStash = true [merge] # See more: https://www.ductile.systems/zdiff3/ conflictStyle = zdiff3 [diff] # Clearer diff output # See more (1): https://luppeng.wordpress.com/2020/10/10/when-to-use-each-of-the-git-diff-algorithms/ # See more (2): https://link.springer.com/article/10.1007/s10664-019-09772-z algorithm = histogram # Use different colors to highlight lines in diffs that have been “moved” colorMoved = default # Ignore indentation changes colorMovedWS = allow-indentation-change # aliases [alias] # # Shortcuts # # Open .gitconfig in default editor conf = config --global -e # Add (stage) files a = add aa = add -A # Commit cm = commit -m empty = commit --allow-empty -m # Add new staged changes to the last commit without changing its message amend = commit --amend --no-edit # Add all modified files to the last commit append = commit -a --amend --no-edit # Status s = status -sb # Unstaged changes (working directory vs. staging area) d = diff # Staged changes (staging area vs. last commit) dc = diff --cached cp = cherry-pick # Push puf = push --force-with-lease put = push --tags # Worktree wta = worktree add wtl = worktree list wtr = worktree remove # Rebase: skip a rebase step skip = rebase --skip # Rebase: abort abort = rebase --abort # Rebase: add changes and continue cont = !git add . && git rebase --continue # Compact and readable log # git l # 30 commits # git l -100 # 100 commits # git l --all # all commits l = "!f() { git log --graph --pretty=format:'%C(magenta)%h%C(auto)%d%Creset %s %C(blue bold)— %cr <%an>%Creset' ${1:--30}; }; f" # Log with list of changed files per each commit ll = log --stat --abbrev-commit # List of my own commits across all branches my = !git log --all --no-merges --pretty=format:'%C(reset)%C(bold)%cd %C(reset)%C(white)%s %C(reset)%h' --date=short --author=\"$(git config user.name)\" # # First-aid # # Undo last commit but don't throw away the changes so they are ready to recommit (affects HEAD only) undo = reset --soft HEAD~1 # Remove files from staging area without discarding changes (mixed reset) unstage = restore --staged . # Discard all unstaged changes in the working tree and revert them to their state in the HEAD commit discard = restore . # Discard ALL local modifications including untracked files and restore repository to last committed state (HEAD) nuke = !git reset --hard && git clean -fd # # Helpers # # Show the user email for the current repository whoami = config user.email # Print all configured aliases aliases = config --get-regexp ^alias\\. # Display the current branch name branchname = branch --show-current # List all contributors sorted by number of commits contribs = shortlog -sn --all --no-merges -- # How many lines of code I have written today today = diff --shortstat \"@{0 day ago}\" # Count number of lines of code in the files of a git project stats = "!git ls-files | xargs wc -l" # Show the most recent commit last = log -1 HEAD # What branches I was working on ordered by last change recent = !git for-each-ref --color --sort=-committerdate --format=$'%(color:blue)%(refname:short)\t%(color:yellow)%(committerdate:relative)\t%(color:default)%(describe)' refs/heads/ --no-merged | sed 's/ /\t/' | column -s=$'\t' -t -c 'Branch Name,Last Commit,Description' | tail -10 # List of files with merge conflicts wtf = diff --name-only --diff-filter=U # Sharable diff with disabled syntax highlighting and +/- marks patch = !git --no-pager diff --no-color # Push up the branch and set upstream for the current branch publish = "!git push --set-upstream origin $(git branch --show-current)" # Include local/private config if relevant (credential helper, SSH, user identity) [include] path = ~/.gitconfig.local