Issue
There is no remote repository for this project yet but it has a remote set in its config and someone did that for some reason so I won’t change it. The original repository is in /home/me/repo1/.git and I ran git clone /home/me/repo1/.git
while in /home/me/repo2 so now it’s cloned in /repo2
When I go into the cloned repo and run git remote set-url origin http://example.com/asdf/.git
both repositories config’s get updated.
I can’t fork the repo because I don’t have admin access and no access to gh cli or similar tools. Is there a workaround to only update the second repository?
Solution
Cannot simulate the issue here, and it makes sense, since the remote tracking configuration is on a per repository basis, could you please check if the performed steps resemble the steps provided below? The intent of the pwd
commands is to demonstrate the current folder in which the subsequent commands are executed.
- Create repo1
$ pwd
/home/user/
$ mkdir repo1
$ cd repo1
$ git init .
Initialized empty Git repository in /home/daniel/Temporary/repo1/.git/
$ git remote add origin http://url.com/repo1.git
- Create repo2
$ pwd
/home/user/
$ mkdir repo2
$ cd repo2
$ git clone ../repo1/.git/
Cloning into 'repo1'...
warning: You appear to have cloned an empty repository.
done.
- Set remote url for cloned repository
$ pwd
/home/user/repo2/repo1
$ git remote set-url origin http://url.com/repo2.git
- Retrieve the remote urls
$ pwd
/home/user/repo1
$ git remote -v
origin http://url.com/repo1.git (fetch)
origin http://url.com/repo1.git (push)
-----
$ pwd
/home/user/repo2/repo1
$ git remote -v
origin http://url.com/repo2.git (fetch)
origin http://url.com/repo2.git (push)
Answered By – dandev486
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0