简体   繁体   中英

Updating a remote server to pull from a renamed Git repo

I have a Git repo which a remote web server is set up to pull from. When I want to update from the active branch I just log-in and run "git pull" and all is good.

I had to rename the repo on Github and updated the reference on my remote webserver using:

git remote set-url origin https://github.com/[organisation]/[repo]

Having done this I ran:

git remote -v

This confirmed that the remote repo name had been updated, however when I run git pull subsequently I get the error:

The requested URL returned error: 403 Forbidden while accessing https://github.com/[organisation]/[repo].git/info/refs

What am I doing wrong? Did I miss a step?

Ah, got it... I was using instructions pertaining to updating if you were connecting over HTTPS, not SSH. The correct command to run in that instance is:

git remote set-url origin git@github.com:[organisation]/[repo].git

From: https://help.github.com/articles/changing-a-remote-s-url/

Note: renaming the remote URL using HTTPS can work too, but you need to setup a Git credential helper .

That would allow to use (one time) your username/password (GitHub account credentials), which would then be cached and reused for any subsequent push/pull/clone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM