Skip to content

Instantly share code, notes, and snippets.

@jmatsu
Last active August 29, 2015 14:02
Show Gist options
  • Save jmatsu/48860e33f1cea8cb0f27 to your computer and use it in GitHub Desktop.
Save jmatsu/48860e33f1cea8cb0f27 to your computer and use it in GitHub Desktop.
Before starting development with using Git, the developer should set .gitconfig.

Global settings

Global settings are written in ~/.gitconfig

Default committer

$ git config --global user.email "Your email"
$ git config --global user.name "Your name"

Color

$ git config --global color.ui auto

Note: color.ui is a set of 'color.branch, color.diff, color.interactive, color.status'
You can set different colors for each color.*

or use diff-highlight (I like this rather than color.ui)

Default packages of git include diff-highlight(https://github.com/git/git/tree/master/contrib/diff-highlight)

Fast-forward or Non fast-forward

If you would like to always merge with non fast-forward (default is fast-forward)

$ git config --global merge.ff false

and if you would like to work with fast-forward when using pull (default is fast-forward)

$ git config --global alias.${name u like} 'pull --ff-only'

or

$ git config --global pull.rebase true

if you use Git2.x

$ git config --global pull.ff only

I like this configs :)

My favorites aliases

$ git config --global alias.stp 'stash'
$ git config --global alias.stq 'stash pop'
$ git config --global alias.stt 'status'

Note: 'status' and 'stash *' are starting with 'sta'
When I want to use 'git status', I often type 'git sta'
In this case, the completion system often suggest 'git stash' to me and then I cannot stop typing enter-key :(

$ git config --global alias.cl 'log'
$ git config --global alias.rl 'reflog'

I hate to spend long time with typing :(

Local settings

Local settings are written in .git/config

$ cd /path/to/local/gitrepo/

you type the commands (which I wrote) which is removed --global

@jmatsu
Copy link
Author

jmatsu commented Jun 14, 2014

Hi gecko655.

That's right. i have a mistake.
Git cannot overwrite its default commands.

So, u should type 'git config --global alias.${name u like} 'pull --ff-only' or 'git config --global pull.rebase true' on Git 1.x
If u update git and get Git 2.x, 'git config --global pull.ff only' works well.
Git 2.x also don't allow overwriting its default commands, but it have a new parameter and value.

Thank u for pointing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment