Git

Git

Git

Tips & Solutions

Config

git config --global http.proxy http://127.0.0.1:1080

# 提交时, \r\n => \n。
git config --global core.autocrlf input

# for Windows, store http credentials:
git config --global credential.helper wincred

Proxy

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

# cancel proxy config
git config --global --unset http.proxy
git config --global --unset https.proxy

禁用 git push 代理:

git config --global --add remote.origin.proxy ""

强制清除本地所有未提交更改

git reset --hard HEAD

Show branches "Tree"

git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"

git lgb

"git pull" vs "git pull --rebase"

Suppose you have two commits in local branch:

      D---E master
     /
A---B---C---F origin/master

After "git pull", will be:

      D--------E  
     /          \
A---B---C---F----G   master, origin/master

After "git pull --rebase", there will be no merge point G. Note that D and E become different commits:

A---B---C---F---D'---E'   master, origin/master

Last update: 2019-05-31 02:30:33 UTC