我如何重命名GitHub上的存储库? [英] How do I rename a repository on GitHub?
问题描述
$ b $我想在GitHub上重新命名我的一个仓库,但是我很害怕b
- 我们不会设置旧位置的任何重定向
- 您需要更新本地存储库以指向新位置
- >重命名可能需要几分钟的时间才能完成
有没有人有分步说明如何手动完成#1和#2?或者我必须在本地做什么?
解决方案如果您是该项目的唯一工作人员,那不是一个大问题,因为你只需要做#2。
假设你的用户名是 someuser
,你的项目名为 someproject
。
然后您的项目URL将为 1
git@github.com:someuser / someproject.git
如果您重命名项目,它将更改URL中的 someproject
部分,例如
git@github.com:someuser / newprojectname.git
(请参阅脚注,如果您的URL不是这样)。
您的 git
的工作副本使用此URL当你做一个推动
或拉
。
在你重命名你的项目后,你将不得不告诉你的工作副本新的URL。
你可以在两个步骤:
首先,cd到你的本地git目录,并找出哪个远程名称引用了该URL
$ git remote -v
$ p $然后,设置新的URL
origin git@github.com:someuser / someproject.git
$ git remote set-url origin git@github.com:someuser / newprojectname.git
或者在旧版本的git中,您可能需要
$ git remote rm origin
$ git remote add origin git@github.com:someuser / newprojectname.git
(origin是最常见的远程名称,但可能被称为别的东西。)
但是,如果有很多人在为您的项目工作,他们都需要完成上述步骤,甚至您甚至不知道如何联系他们以告诉他们。这是#1的一部分。
更多阅读:
- github - 使用遥控器
- Git Reference - 遥控器
1 URL的确切格式取决于您使用的协议,例如
- SSH = git @ github.com:someuser/someproject.git
- HTTPS = https ://someuser@github.com/someuser/someproject.git
- GIT = git://github.com/someuser/someproject.git
I wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said:
- We will not set up any redirects from the old location
- You will need to update your local repositories to point to the new location
- Renaming may take a few minutes to complete
Does anyone have step-by-step instructions on how to accomplish #1 and #2 manually? Or what do I have to do locally?
解决方案If you are the only person working on the project, it's not a big problem, because you only have to do #2.
Let's say your username is
someuser
and your project is calledsomeproject
.Then your project's URL will be1
git@github.com:someuser/someproject.git
If you rename your project, it will change the
someproject
part of the URL, e.g.git@github.com:someuser/newprojectname.git
(see footnote if your URL does not look like this).
Your working copy of
git
uses this URL when you do apush
orpull
.So after you rename your project, you will have to tell your working copy the new URL.
You can do that in two steps:
Firstly, cd to your local git directory, and find out what remote name(s) refer to that URL
$ git remote -v origin git@github.com:someuser/someproject.git
Then, set the new URL
$ git remote set-url origin git@github.com:someuser/newprojectname.git
or in older versions of git, you might need
$ git remote rm origin $ git remote add origin git@github.com:someuser/newprojectname.git
(origin is the most common remote name, but it might be called something else.)
But if there's lots of people who are working on your project, they will all need to do the above steps, and maybe you don't even know how to contact them all to tell them. That's what #1 is about.
Further reading:
Footnotes:
1 The exact format of your URL depends on which protocol you are using, e.g.
- SSH = git@github.com:someuser/someproject.git
- HTTPS = https://someuser@github.com/someuser/someproject.git
- GIT = git://github.com/someuser/someproject.git
这篇关于我如何重命名GitHub上的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!