This is a little doc I put together to help remember how to get back to my desired git config. It also has some useful commands that I have picked up from lessons learned in dealing with large development teams and managing lots of pull requests.
Hope this will help others as well
Will simply setup the username and email address to publish commits under. Use the --global
flag if you want to use the same information by default for all projects.
git config user.name <username>
git config user.email <email>
My favorite is to use current
, which Setup push current branch only AND will automatically create upstream branches if they do not exist!
Requires Git 2.0+
git config --global push.default current
If you are in a situation where SSH keys are not feasible and you must use password access, you are probably beyond fed-up with typing your password in consistently. Good news is that you can setup a password cache within Git to keep you from having to constantly type it in. You basically just give the command below the time (in seconds) that you want to cache your credentials. I typically use 10hr or 36000s, this way, I type it in once per day, usually when I get into work in the morning.
git config credential.helper 'cache --timeout=<time-in-seconds>'
This command assists the developer in this process by recording conflicted automerge results and corresponding hand resolve results on the initial manual merge, and applying previously recorded hand resolutions to their corresponding automerge results. Enable it by:
git config --global rerere.enabled true
In environments where developers are working on all different types of base operating systems, you are probably driving yourself nuts with pull requests where the diffs are 90% line endings differences. The following commands will force <LF>
line endings and not <CRLF>
. You can always override per repo by running the commands w/o the --global
flag.
git config --global core.autocrlf false
git config --global core.eol lf
For you java/maven guys:
This allows for versions in pom files to not get overwritten when syncing between branches on different version numbers. Add the following to your gitconfig
[merge "pommerge"]
name = A custom merge driver for Maven's pom.xml
driver = mergepom.py %O %A %B
Then,
cp $download-dir/mergepom.py <somewhere-in-execution-path>
you will need python installed, of course. This will run automagically when merging. Script attached