Skip to content

Git - change remote URL

When do you need this?

  • When you cannot push your local commit to remote repository by:
    • URL not found error
    • Authentication error (If the remote path gets to “https://gitlab.xxx.xx/“, HTTPS requires ID/password in command line or Windows credential popup etc.)

How to fix it?

Check remote url

1
2
3
$ git remote -v
origin  https://gitlab.fabcloud.org/academany/fabacademy/2021/labs/kannai/students/hisami-takezawa.git (fetch)
origin  https://gitlab.fabcloud.org/academany/fabacademy/2021/labs/kannai/students/hisami-takezawa.git (push)

Check SSH configuration

1
2
$ ssh -T git@gitlab.fabcloud.org
Welcome to GitLab, @takezawa.h!

Change remote URL

1
$ git remote set-url origin git@gitlab.fabcloud.org:academany/fabacademy/2021/labs/kannai/students/hisami-takezawa.git

Re-check remote url

1
2
3
$ git remote -v
origin  git@gitlab.fabcloud.org:academany/fabacademy/2021/labs/kannai/students/hisami-takezawa.git (fetch)
origin  git@gitlab.fabcloud.org:academany/fabacademy/2021/labs/kannai/students/hisami-takezawa.git (push)

Last update: April 9, 2021