为什么github在git将文件推送到/var/www/html时询问用户名和密码?
我在为什么github在git将文件推送到/var/www/html时询问用户名和密码?,git,authentication,passwords,Git,Authentication,Passwords,我在.netrc中设置用户名和密码 cat .netrc machine github.com login myname password mypassword git推送/tmp目录中的文件: 为此推入github的网页创建一个新的repo测试tmp Github不要求用户名和密码,git推送成功 git推送文件在/var/www/html/cal目录中: 为此推送github的网页创建一个新的回购测试var。 注意:所有的sudo都不能省略,对于/var/w
.netrc
中设置用户名和密码
cat .netrc
machine github.com
login myname
password mypassword
/tmp
目录中的文件:为此推入github的网页创建一个新的repo
测试tmp
git推送
成功
/var/www/html/cal
目录中:为此推送github的网页创建一个新的回购
测试var
。注意:所有的
sudo
都不能省略,对于/var/www/html
中的文件,没有sudo
的git命令会导致如下错误:
错误:无法锁定配置文件/var/www/html/cal/.git/config
:权限被拒绝
Username for 'https://github.com': xxxx
Password for 'https://gitsnippet@github.com': xxxx
当git在
/var/www/html
中推送文件时,如何让githtb在.netrc
中读取用户名和密码?以sudo
方式推送意味着:
- 不同的
设置:检查git-config
(与sudo-git-config-credential.helper
相比)git-config-credential.helper
- 不同的
(其中sudo ls~/.netrc可能不存在)$HOME
git config
和.netrc
)在这两个环境中都存在
sudo cp $HOME/.netrc /root/.netrc
Username for 'https://github.com': xxxx
Password for 'https://gitsnippet@github.com': xxxx
sudo cp $HOME/.netrc /root/.netrc