基本功能

全局用户名和邮箱

git config --global user.name redquilt
git config --global user.email "[email protected]"

全局pull时自动rebase

git config --global --add pull.rebase true

保存gitee和github的密码

执行以下命令后,再输入的github和gitee账号和密码就可以被保存下来

git config --global credential.helper store

通过代理拉取项目

git clone -c http.proxy="proxy.company_name.com:8888" https://github.com/jonny-xhl/FastReport.git

放弃本地所有更改

还没有暂存:

git checkout . && git clean -df

已经暂存了还没有提交:

git reset --hard && git clean -df

已经提交了,还没有推送:

git reset --hard HEAD^ && git clean -df

已经推送了:
那就没救了,只能revert

疑难杂症

Git error: no matching host key type found. Their offer: ssh-rsa

找到你安装的git目录,比如C:\Program Files\Git
在该目录下找到该文件,在末尾加入以下内容:
C:\Program Files\Git\etc\ssh\ssh_config

Host *
    KexAlgorithms +diffie-hellman-group1-sha1
    HostkeyAlgorithms +ssh-dss,ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-dss,ssh-rsa

接着保存退出即可