离开 Github,如何更改 Git 存储库的来源?
我在 Github 上托管一个项目,但现在我购买了 Dreamhost 计划,其中包括 shell 访问和 Git。
Github [Origin]
/ \
pull/ \pull
/push push\
/ \
Laptop Dreamhost
(cloned) (cloned)
我想从 Github 删除我的存储库,并开始直接推送到 DH。
如何更改笔记本电脑中的来源,以及是否应该删除 Dreamhost 中的来源?
I'm hosting a project in Github, but now I purchased a plan with Dreamhost that includes shell access and Git.
Github [Origin]
/ \
pull/ \pull
/push push\
/ \
Laptop Dreamhost
(cloned) (cloned)
I would like to delete my repo from Github, and starting push directly to DH.
How do I change origin in my Laptop, and should I delete the origin in Dreamhost?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我更喜欢使用“git remote”命令,而不是手动处理 .git/config 文件。
I prefer using the 'git remote' command instead of screwing about with the .git/config file by hand.
最简单的方法是:
在此之后显示遥控器:
The easiest way is:
You show the remotes after this:
最好的方法是 git remote set-url origin
The best way is to
git remote set-url origin <new-url>
最简单的方法是在笔记本电脑上编辑 .git/config 文件。只需搜索您的 github 网址并将其替换为 DreamHost 中的网址即可。确保您的 ssh 公钥已在 Dreamhost 上设置。现在您可以推送 origin master,并且您将填充您的 dreamhost 存储库。
您可以删除dreamhost上的origin,但没有必要。
另外,请确保那里的存储库是裸露的。默认情况下,您无法推送到非裸存储库。
The easiest way is to edit your .git/config file on your laptop. Simply search for your github url and replace it with the one from DreamHost. Make sure that your ssh public key is set on Dreamhost. Now you can push origin master and you will have populated your dreamhost repository.
You can delete origin on dreamhost but there is no need.
Also, ensure that the repository that is there is bare. By default, you cannot push to non-bare repositories.
最简单的方法是编辑
.git/config
文件,其中列出了源所在的位置。您可以通过运行 git fetch 来测试它。如果您愿意,可以在同一个文件中删除 Dreamhost 端的远程引用。
The easiest way is to edit your
.git/config
file, which lists where the origin lives. You can test it by running agit fetch
You can delete the remote references on the Dreamhost side if you like, in the same file.
为什么不简单地:
why not simply :