博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在GitHub上重命名存储库?
阅读量:2291 次
发布时间:2019-05-09

本文共 5684 字,大约阅读时间需要 18 分钟。

本文翻译自:

I wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said: 我想在GitHub上重命名我的一个存储库,但是当一个大红色警告说:

  1. We will not set up any redirects from the old location 我们不会从旧位置设置任何重定向
  2. You will need to update your local repositories to point to the new location 您需要更新本地存储库以指向新位置
  3. Renaming may take a few minutes to complete 重命名可能需要几分钟才能完成

Does anyone have step-by-step instructions on how to accomplish #1 and #2 manually? 有没有人有关于如何手动完成#1和#2的分步说明? Or what do I have to do locally? 或者我必须在本地做什么?


#1楼

参考:


#2楼

It is worth noting that if you fork a GitHub project and then rename the newly spawned copy, the new name appears in the members network graph of the parent project. 值得注意的是,如果您分叉GitHub项目然后重命名新生成的副本,则新名称将显示在父项目的成员网络图中。 The complementary relationship is preserved as well. 互补关系也得以保留。 This should address any reservations associated with the first point in the original question related to redirects, ie you can still get here from there, so to speak. 这应该解决与原始问题中与重定向相关的第一点相关的任何保留,即您仍然可以从那里到达这里,可以这么说。 I, too, was hesitant because of the irrevocability implied by the warning, so hopefully this will save others that delay. 我也是犹豫不决,因为警告暗示了不可撤销性,所以希望这会挽救其他延迟。


#3楼

This answer is now obsolete! 这个答案现在已经过时了! GitHub will forward to new locations now. GitHub现在将转发到新的位置。 See for details. 有关详情,请参阅 。


The reason this warning is there is because #1 can't be made manually. 这个警告的原因是因为#1 不能手动制作。

If you are the only person working on and linking to the repository, then you are fine with changing the remote in your local repo and in your webpages. 如果您是唯一一个处理和链接到存储库的人,那么您可以更改本地存储库和网页中的遥控器。

However, the reason to have a public repository on github in the first place is that you can have others cloning your repository and linking to your github project page. 但是,首先在github上拥有公共存储库的原因是,您可以让其他人克隆您的存储库并链接到您的github项目页面。


The old url github.com/<username>/<repository> is owned by github. 旧网址github.com/<username>/<repository>归github所有。 When they don't setup any redirects to the new url, nobody can. 当他们没有设置任何重定向到新网址时,没有人可以。 So things will break for everybody except the persons you are telling. 因此,除了你所说的人之外,每个人都会受到打击。

How big of a problem that is, is up to you though. 然而,问题有多大,取决于你。 If you have an official project page on a different server, then the github url might not be much of a problem. 如果你在不同的服务器上有一个官方项目页面,那么github url可能不是什么大问题。 If you advertised your project with the github url in mailing lists and directories, then you probably should not change the repo name. 如果您在邮件列表和目录中使用github url通告了您的项目,那么您可能不应该更改repo名称。


An alternative to changing the repo name is to create a new repository and leave notes in the old one (also as commits in the repo) about how to reach your new repo. 更改repo名称的另一种方法是创建一个新的存储库,并在旧的存储库中保留注释(也作为repo中的提交),以了解如何访问新的存储库。

If you wan't your new repo to be listed as a fork of your old repo you need to create a new github account. 如果您不想将新的仓库列为旧仓库的分支,则需要创建一个新的github帐户。 You can add your other account as a collaborator for both repositories. 您可以将其他帐户添加为两个存储库的协作者。


#4楼

I rename my own just by simply : 我简单地重命名自己:

  1. going to github.com on my repository 在我的存储库上访问github.com
  2. Open Settings Tab 打开设置选项卡
  3. The first setting you can see is the "Repository Name" 您可以看到的第一个设置是“存储库名称”
  4. Change the actual one and put the new name you want to give to your repository 更改实际的名称并将要添加的新名称添加到存储库
  5. Click on Rename 单击重命名

After this step, GitHub will make sure that, your online repository matches your local folder name. 完成此步骤后,GitHub将确保您的在线存储库与您的本地文件夹名称匹配。 At this step your problem is solved, unless you also want to rename your local folder. 此步骤解决了您的问题,除非您还想重命名本地文件夹。 Then do it manually and just use the Github client for windows to refind again your repository into your hard drive, and Github will match it again. 然后手动执行,只需使用Github客户端再次将您的存储库重新刷新到您的硬盘驱动器中,Github将再次匹配它。 That's all! 就这样! Very simple. 非常简单。


#5楼

Note that since May 2013 (" "), you can rename your GitHub repo without breaking any links: 请注意,自2013年5月(“ ”),您可以重命名您的GitHub 而不会破坏任何链接:

We're happy to announce that starting today, we'll automatically redirect all requests for previous repository locations to their new home in these circumstances. 我们很高兴地宣布,从今天开始,在这些情况下,我们会自动将以前存储库位置的所有请求重定向到新家。 There's nothing special you have to do. 你不需要做什么特别的事。 Just rename away and we'll take care of the rest. 只需重新命名,我们将照顾其余部分。

As a special bonus, we'll also be servicing all Git clone, fetch, and push requests from previous repository locations . 作为特殊奖励, 我们还将为以前存储库位置的所有Git克隆,获取和推送请求提供服务

That means you don't even have to git remote set-url (change the url of your remote GitHub repo) on your local cloned repo! 这意味着您甚至不必在本地克隆仓库上使用git remote set-url (更改远程GitHub仓库的URL)!

Although notes that the strongly recommends that you do so: 尽管 指出强烈建议您这样做:

to reduce confusion, we strongly recommend updating any existing local clones to point to the new repository URL. 为了减少混淆,我们强烈建议您更新任何现有的本地克隆以指向新的存储库URL。 You can do this by using git remote on the command line: 您可以在命令行上使用git remote来执行此操作:

git remote set-url origin new_url

Beware though: 请注意:

sites are not automatically redirected when their repositories are renamed at this time. 网站在此时重命名其存储库时不会自动重定向。

Renaming a Pages repository will continue to break any existing links to content hosted on the github.io domain or custom domains. 重命名页面存储库将继续破坏任何现有的链接到github.io域或自定义域上托管的内容。

Plus, the user still owns the namespace : if he/she creates a new repo using the old name of the renamed repo, that redirection (for said renamed repo) will stop working. 此外, 用户仍然拥有命名空间 :如果他/她使用重命名的repo的旧名称创建的repo,则该重定向(对于所述重命名的repo)将停止工作。


#6楼

Simple solution: 简单方案:

1) Open your project url: 1)打开您的项目网址: :

2) in the top, aside of the project name, click EDIT 2)在顶部,除项目名称外,单击EDIT

转载地址:http://egcnb.baihongyu.com/

你可能感兴趣的文章