We covered some git basics in my earlier post. Here are 5 Must Have settings that make your life with git easier.
1. Get colored git diff output
To get colored git diff output, run
config indicates to git that this change needs to be set in config.
–global flag indicates that this config would be set globally for all your projects and not just for the current project
2. Tab Completion for git commands
The following settings lets you setup auto completion for git commands. These instructions are available for bash. I haven’t checked the instructions out with any other shell.
For this you need to download two files git-completion.bash and git-prompt.sh.
- You can download git-completion.bash from here. Once you download make sure that the file is named as git-completion.bash.
- You can download git-prompt.sh from here. Once you download, make sure that the file is named as git-prompt.sh
- Add the following configuration to .bash_profile. You can find this in your home directory on OSx or linux variants. The dot at the beginning of the filename indicates that it is a hidden file. You will have to use
ls -la
to see the files. Create the file if it doesn’t exist.
3. Configuring your name and email
- Run
git config --global user.name "Your name"
- Run
git config --global user.email "Youremailid@domain.com"
Fill your own name and email address where indicated.
4. Set up a default editor for git
Sometimes git will automatically open a text editor. You can setup this default to an editor of your choice.
- Make sure you can open your editor from command line.
- Run the command
git config --global core.editor
, followed by the command you run to start your editor. You will need to give the full path to editor.
5. Setting up push default and merge conflict style
- Run
git config --global push.default upstream
- Run
git config --global merge.conflictstyle diff3
PS: Do not forget to restart your terminal for any of these changes to take effect.