Optimize Git Configuration Settings
Maximize efficiency and streamline your Git workflow with essential configuration settings.
Config
Set email
git config --global user.email "user@localhost"
Set username
git config –global user.name "user"
Set editor
git config --global core.editor "vim"
Merge tools
git config --global merge.tool vimdiff
Set aliases
In this example you can use git ci
instead of git commit
git config --global alias.ci commit
Setup GPG
git config --global --unset gpg.format
signKey="$(gpg --list-secret-keys --keyid-format=long|grep -i sec|cut -d'/' -f2|cut -d' ' -f1)"
git config --global user.signingkey $signKey
git config --global commit.gpgsign true
[ -f ~/.bashrc ] && echo -e '\nexport GPG_TTY=$(tty)' >> ~/.bashrc
Telling Git about your SSH key
git config --global gpg.format ssh
git config --global user.signingkey /PATH/TO/.SSH/KEY.PUB
Push origin
git push --set-upstream origin main
List gpg key for add to ~/.gitconfig
gpg --list-secret-keys --keyid-format=long
Colored outputs
git config --global color.ui false
To query the value for a given key, do
git config --get core.filemode
Configure global settings
git config --global --edit
Reset author
git commit --amend --reset-author
Set default branch name
git config --global init.defaultBranch main
Add repository to gitea
touch README.md
git init
git checkout -b main
git add README.md
git commit -m "first commit"
git remote add origin http://192.168.1.181:3000/wuseman/vim.git
git push -u origin main
Switching remote URLs from HTTPS to SSH
git remote set-url origin http://192.168.1.181:3000/wuseman/vim
Git, fatal: The remote end hung up unexpectedly
- Fix this by raise postBuffer
git config http.postBuffer 524288000