Git config and more
I made this gist to go deeper in my git customisation and keep track of them.
- Read this post for setting up a custom git prompt.
- Read this gist from @porteneuve explaining an evolved .gitconfig.
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.
Sugar
git config --global diff.mnemonicPrefix true
: in diffs, instead ofa/
,b/
, get prefixes likec
(for commit),i
(for index/staged),w
(for working directory) ...git config --global diff.renames true
: tells Git diff to detect renames