1

Your Global .gitconfig

 3 years ago
source link: https://fuzzyblog.io/blog/git/2020/03/03/your-global-gitconfig.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Your Global .gitconfig

Mar 3, 2020

IMG_2192.jpeg

I had a question recently about my use of git trash which isn't a standard git command. I accomplished this, about a decade ago, by modifying ~/.gitconfig and, well, I haven't thought about it ever since. Here's my ~/.gitconfig as an example.

[color]
diff = auto
status = auto
branch = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[user]
name = Scott Johnson
email = [email protected]
[alias]
co = checkout
st = status
br = branch
trash = checkout -f
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[apply]
whitespace = nowarn
[core]
excludesfile = /Users/sjohnson/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path = 
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process
[push]
default = simple

The key thing, to support git trash, is the [alias] section. This is where you can define your own custom commands based on the fundamental git primitives. My git lg command is also pretty nice (and courtesy from Sean Kennedy).

Another really, really useful thing is the excludesfile setting which lets you tell git to never, ever worry about a file like the cursed .DS_Store files which OSX persists in generating.

This is generally stored in something like /Users/username/.gitignore_global.


Posted In: #git


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK