开发者

Git Pull: Change Authentication

开发者 https://www.devze.com 2023-01-22 13:36 出处:网络
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, mak

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.

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).

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 t开发者_如何学编程he testing server to pull changes using MY authentication (kovshenin) and not user1's.

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.


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.


To me. If the issue is changing authentication from https to ssh (https kind of no longer works anyway), I do:

git remote rm origin
git remote add origin git@github.com:etc/etc.git
0

精彩评论

暂无评论...
验证码 换一张
取 消