Skip to content

Instantly share code, notes, and snippets.

@topheman topheman/.gitconfig
Last active Jun 5, 2018

Embed
What would you like to do?
To keep track of my git config
[core]
excludesfile = /Users/Tophe/.gitignore_global
editor = vi
[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
[user]
name = Christophe Rosset
email = tophe@topheman.com
[alias]
st = status
ci = commit
lg = log --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ar)%Creset'
ll = log -10 --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ar)%Creset'
oops = commit --amend --no-edit
[status]
showUntrackedFiles = all
[merge]
conflictStyle = diff3
tool = p4mergetool
[credential]
helper = osxkeychain
[diff]
tool = p4mergetool
mnemonicPrefix = true
renames = true
[difftool "p4mergetool"]
cmd = ~/Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTE
[mergetool "p4mergetool"]
cmd = ~/Applications/p4merge.app/Contents/Resources/launchp4merge $PWD/$BASE $PWD/$REMOTE $PWD/$LOCAL $PWD/$MERGED
trustExitCode = false
prompt = false
[mergetool]
keepBackup = false
[color]
ui = true

Git config and more

I made this gist to go deeper in my git customisation and keep track of them.

You will also find my .gitconfig file.

Setup a visual merge/diff tool

Sometimes, git diff won't be enough. Git lets you use any visual diff/merge tool (like opendiff shipped with sourcetree or p4merge, the one that I will use) with the git difftool or git mergetool.

Install & config p4merge

$ brew update
$ brew cask install caskroom/homebrew-cask/p4merge
$
$ git config --global diff.tool p4mergetool
$ git config --global difftool.p4mergetool.cmd "~/Applications/p4merge.app/Contents/Resources/launchp4merge \$LOCAL \$REMOTE"
$
$ git config --global merge.tool p4mergetool
$ git config --global mergetool.p4mergetool.cmd "~/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED"
$ git config --global mergetool.p4mergetool.trustExitCode false
$ git config --global mergetool.keepBackup false
$ git config --global mergetool.p4mergetool.prompt false

If you don't want to install it from the command line, you can download it from here - (it won't be installed in ~/Applications but in /Applications).

Force Git to clone with "https://" instead of "git://" urls

If you can't clone a repository with a "git://" url because of a proxy or firewall, here is a little git configuration that will force git to use "https://" even when you'll type "git://" URL.

git config --global url."https://".insteadOf git://

With this command, it will add the following lines in you .gitconfig :

[url "https://"]   
    insteadOf = git://

It can be usefull when using tools like bower when you have no control over the protocol (https or ssh) you want to you use when cloning.

sources

Sugar

  • git config --global diff.mnemonicPrefix true: in diffs, instead of a/, b/, get prefixes like c (for commit), i (for index/staged), w (for working directory) ...
  • git config --global diff.renames true: tells Git diff to detect renames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.