省的自己总是忘。

Check the ‘config’ of git

For ‘global’

git config --global --list

Location: ~/.gitconfig, sometime at ~/.config/git/config. On Windows: C:\Users\<username>\.gitconfig

Another one, but I think we don’t typically use it? (i.e. we only need to tweak the global one for most of the times)

git config --list

Change the default editor to ‘vim’

git config --global core.editor "vim"

Set username and email for a repo

For just one repo, go into to the relevant repo DIR and:

git config user.name "Your Name Here"
git config user.email your@email.example

Set username and email for global

For (global) default email (which is configured in your ~/.gitconfig):

git config --global user.name "Your Name Here"
git config --global user.email your@email.example

You can check your Git settings with: git config user.name && git config user.email

If you are in a specific repo which you setup a new user/config for (different to global) then it should show that local config, otherwise it will show your global config.

Set default branch to main

git config --global init.defaultBranch main

Change the default main branch behavior from rebase to merge

git config --global pull.rebase false

Stop using pager

如果你发现每次 git branch 的时候都像自动进了一个 less 里面,就是这个问题了。 (注意这个知识针对 git branch,别的命令不受下面这个东西的影响,不过估计也是可以通过 pager.xxx 来控制的。)

Otherwise, I found my git branch output is always piped to a less.

git config --global pager.branch false