离开 Github,如何更改 Git 存储库的来源?

发布于 2024-09-05 09:40:27 字数 342 浏览 4 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

徒留西风 2024-09-12 09:40:27
git remote rename origin github
git remote add origin <DreamHost-git-URL>
# test and make sure the DreamHost origin works properly for fetch and push
git remote rm github

我更喜欢使用“git remote”命令,而不是手动处理 .git/config 文件。

git remote rename origin github
git remote add origin <DreamHost-git-URL>
# test and make sure the DreamHost origin works properly for fetch and push
git remote rm github

I prefer using the 'git remote' command instead of screwing about with the .git/config file by hand.

沫尐诺 2024-09-12 09:40:27

最简单的方法是:

$ git config remote.origin.url <Dreamhost-git-URL>

在此之后显示遥控器:

$ git remote -v
origin Dreamhost-git-URL (fetch)
origin Dreamhost-git-URL (push)

The easiest way is:

$ git config remote.origin.url <Dreamhost-git-URL>

You show the remotes after this:

$ git remote -v
origin Dreamhost-git-URL (fetch)
origin Dreamhost-git-URL (push)
月朦胧 2024-09-12 09:40:27

最好的方法是 git remote set-url origin

The best way is to git remote set-url origin <new-url>

ゞ记忆︶ㄣ 2024-09-12 09:40:27

最简单的方法是在笔记本电脑上编辑 .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.

冰之心 2024-09-12 09:40:27

最简单的方法是编辑 .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 a git fetch

You can delete the remote references on the Dreamhost side if you like, in the same file.

染墨丶若流云 2024-09-12 09:40:27

为什么不简单地:

git remote remove origin

git remote add origin <Dreamhost-git-URL>

git push -u origin --all --tags

why not simply :

git remote remove origin

git remote add origin <Dreamhost-git-URL>

git push -u origin --all --tags
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文