[英]Change Git Repository for pull code
I have a repository, say abc/myprject.git
. 我有一个存储库,比如说
abc/myprject.git
。 I have this repo on a server from where I pull my code. 我在服务器上有这个repo,我从中获取代码。 Now I have forked this repository, naming it
chirag/myproject.git
. 现在我已经分叉了这个存储库,命名为
chirag/myproject.git
。
I have two questions, with regards to this: 关于这个,我有两个问题:
chirag/myproject.git
repo instead of the original one now, so how do I change it on the server from abc/myproject.git
to the forked one chirag/myproject.git
? chirag/myproject.git
repo而不是原来的,所以如何在服务器上将它从abc/myproject.git
更改为forked one chirag/myproject.git
? abc/myproject.git
, will it cause any issues with chirag/myproject.git
? abc/myproject.git
,是否会导致chirag/myproject.git
任何问题? Thanks 谢谢
Use git remote set-url
to change the URL of the origin
remote (if you didn't change anything, the remote repository will be named origin
). 使用
git remote set-url
更改origin
远程的URL(如果没有更改任何内容,则远程存储库将命名为origin
)。
git remote set-url origin git://someserver/chirag/myproject.git
If there's no "physical" relationship between the both repositories at abc/myproject.git
and chirag/myproject.git
you won't run into any problems when deleting the first one. 如果
abc/myproject.git
和chirag/myproject.git
的两个存储库之间没有“物理”关系,则在删除第一个存储库时不会遇到任何问题。 Git is a distributed version control system that produces full, independent repositories upon cloning. Git是一个分布式版本控制系统,可在克隆时生成完整,独立的存储库。 With "physical" relationship" I mean something like softlinks when both repositories reside on the same filesystem or something similar.
使用“物理”关系“当两个存储库都驻留在相同的文件系统或类似的东西时,我的意思是软链接。
git config -l
will display the remote origin (ie where the server will try and pull from) 将显示远程原点(即服务器将尝试从哪里拉出)
You can remove the current remote with 您可以删除当前的遥控器
git remote rm origin
and then add your new repo instead... 然后添加新的repo而不是......
git remote add origin username@10.0.0.1:chirag/myproject.git
There shouldnt be a problem with then deleteing your original repo and just using the chirag one, although would suggest testing the new setup works before doing that. 那么删除你的原始仓库并且只使用chirag会不应该有问题,尽管建议在这之前测试新的设置。
You could also add the chirag repo as a second remote to the server, just call it something else eg 您还可以将chirag repo作为第二个远程添加到服务器,只需将其称为其他内容,例如
git remote add chirag username@10.0.0.1:chirag/myproject.git
And then just pull from it rather than origin 然后从它而不是原点拉出来
git pull chirag master
ps. PS。 throughout the example code I've assumed that on the server, the name of the remote to pull form is origin - change the name if its called something else
在整个示例代码中,我假设在服务器上,拉取表单的远程名称是原点 - 如果名称调用其他名称则更改名称
HTH Doug HTH Doug
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.