notes
notes copied to clipboard
git配置备忘 or git config
git 全局配置备忘
涉及到代理,commiter,编码及换行等。
[core]
eol = lf
bare = false
fscache = true
autocrlf = input
filemode = false
ignorecase = false
preloadindex = true
logallrefupdates = true
precomposeunicode = true
repositoryformatversion = 0
[gc]
auto = 256
[gui]
encoding = utf-8
[pull]
rebase = false
[credential]
# macos 钥匙串(对应的是名为 github.com 的 token => personal access token)
helper = osxkeychain
[oh-my-zsh]
hide-dirty = 1
hide-status = 1
[user]
name = <your name>
email = <your email>
[i18n]
commitEncoding = utf-8
logOutputEncoding = utf-8
[http]
proxy = "socks5://127.0.0.1:1080"
postBuffer = 524288000
[https]
proxy = "socks5://127.0.0.1:1080"
postBuffer = 524288000
如果出现如下情形,可能是代理设置有问题。
$ brew update
fatal: unable to access 'https://github.com/Homebrew/brew/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/caskroom/homebrew-cask/': Could not resolve host: github.com
Error: Fetching /usr/local/Homebrew failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask failed!
删除 git 全局代理的指令
git config --global --unset http.proxy
git config --global --unset https.proxy
git 项目配置备忘
1. 直接利用全局 .gitconfig 的 personal access token
[remote "origin"]
url = https://github.com/<your name or your org name>/<project name>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
2. 将 personal access token 写入项目 git 配置中
[remote "origin"]
url = https://oauth2:<your personal access token>@github.com/<your name or your org name>/<project name>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
说明:
从2020年底开始, github 通过 https 访问私有项目强制要求使用 personal access token, 不再支持 user:pass 形式的访问。
例子 2 中的 oauth2:
git 项目 ssh 访问参考
#51 如何科学访问github or github ssh proxy