[英]How to set a git repository's remote url without updating the local repository it's cloned from?
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原始存储库在 /home/me/repo1/.git 中,我在 /home/me/repo2 中运行git clone /home/me/repo1/.git
所以现在它在 /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.当我进入克隆的 repo 并运行git remote set-url origin http://example.com/asdf/.git
两个存储库配置都会更新。
I can't fork the repo because I don't have admin access and no access to gh cli or similar tools.我无法分叉 repo,因为我没有管理员访问权限,也没有访问 gh cli 或类似工具的权限。 Is there a workaround to only update the second repository?是否有仅更新第二个存储库的解决方法?
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. pwd
命令的目的是演示执行后续命令的当前文件夹。
$ 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
$ pwd
/home/user/
$ mkdir repo2
$ cd repo2
$ git clone ../repo1/.git/
Cloning into 'repo1'...
warning: You appear to have cloned an empty repository.
done.
$ pwd
/home/user/repo2/repo1
$ git remote set-url origin http://url.com/repo2.git
$ 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.