Linux Git Pull:更改身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4041087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Pull: Change Authentication
提问by kovshenin
I'm quite new to git. I have a repo setup on a server (A) where access is via ssh rsa keys. I have a few users there including myself. Now I do git clone
on my local machine and get a local copy, make changes, and push origin master
, everything works fine.
我对 git 很陌生。我在服务器 (A) 上有一个 repo 设置,其中访问是通过 ssh rsa 密钥进行的。我有一些用户,包括我自己。现在我git clone
在我的本地机器上做并获取本地副本,进行更改,并且push origin master
一切正常。
The problem I'm experiencing is that our testing server (server B) already has everything setup and what I'd like to do is pull my latest changes to that server. The testing server has also got several users, as well as www-data
as the owner of the whole directory (running Apache).
我遇到的问题是我们的测试服务器(服务器 B)已经完成了所有设置,我想做的是将我的最新更改拉到该服务器上。测试服务器也有几个用户,以及www-data
整个目录的所有者(运行 Apache)。
When logging in via SSH using my name, I cannot git pull
, says .git is locked, so I do sudo git pull
which asks me the password for a different user (user1). I do not know that password and I'd like to remove that user completely, but before I do, I have to switch the git repo on the testing server to pull changes using MY authentication (kovshenin) and not user1's.
当使用我的名字通过 SSH 登录时,我不能git pull
,说 .git 被锁定,所以我这样做了sudo git pull
,询问我不同用户(user1)的密码。我不知道那个密码,我想完全删除该用户,但在此之前,我必须切换测试服务器上的 git repo 以使用我的身份验证(kovshenin)而不是 user1 来提取更改。
What's the correct way to do that? I wouldn't like to remove everything and start from a fresh clone, since it has some local changes.
这样做的正确方法是什么?我不想删除所有内容并从新的克隆开始,因为它有一些本地更改。
采纳答案by kovshenin
After three hours of searching and playing I have found the answer myself. The authentication details are stored in the .git/config
file under the url
setting in the [remote "origin"]
section.
经过三个小时的搜索和播放,我自己找到了答案。身份验证详细信息存储在该部分设置.git/config
下的文件url
中[remote "origin"]
。