我已经将我的私有 Github存储库克隆到了CentOS 6计算机(git版本1.7.1)上。我可以以某种方式设置本地git存储库,以便在键入时始终提示输入用户名和密码git push吗?
并非总是使用相同的用户名。
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/USER/PRIVATE-REPO.git
[branch "master"]
remote = origin
merge = refs/heads/master
Run Code Online (Sandbox Code Playgroud)
当我git push现在表演时,我得到以下信息:
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Industriromantik/render-linux.git/info/refs
fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)
如果执行以下命令,则推送成功:
git push https://MY-GITHUB-USERNAME@github.com/USER/PRIVATE-REPO
Run Code Online (Sandbox Code Playgroud)
......不过,我要求只执行git push并得到提示两者的用户名和密码,如果在所有可能的。
https://help.github.com/articles/caching-your-github-password-in-git/
尝试使用您的用户名添加 gitconfig,如下链接
https://gist.github.com/pksunkara/988716