How to see to which Github repo and existing Git repo belongs to – and then change it

Issue:

You’ve just taken over a website after the 2nd service provider let the client down. Usual problem, the developer’s communication is terrible.

  1. Determine the remote original URLgit remote -v or git config –get remote.origin.url

2. Set a new remote original URL:

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

3. Check your work

git remote -v

You then do:

git fetch && git pull expecting it to work. Instead you get:

fatal: refusing to merge unrelated histories

Solution:

git pull –allow-unrelated-histories

References:

https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr
https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase

References:

git reset –hard origin/master

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top