重命名在 BitBucket 上配置的 git 项目的最简单方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25507951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Easiest way to rename git project configured on BitBucket
提问by Paul Taylor
I have a project hosted on BitBucket
我在 BitBucket 上托管了一个项目
Can I rename it ?
我可以重命名吗?
If not and I need to create a new repository can someone tell me the easiest way to do that and have new repo on BitBucket (one particular cause of confusion for me is whether to drive the process locally or from the bitbucket website)
如果没有并且我需要创建一个新的存储库,有人可以告诉我最简单的方法来做到这一点并在 BitBucket 上拥有新的存储库(让我感到困惑的一个特殊原因是是在本地还是从 bitbucket 网站驱动该过程)
Update
更新
Thankyou Rafal I've followed your instructions and it works great but Im just going to make it a little clearer for noobies like myself (on linux)
谢谢你 Rafal 我已经按照你的指示做了,效果很好,但我只是想让像我这样的菜鸟更清楚一点(在 linux 上)
- In Bitbucket project settings rename project
- vi projectname/.git/config and edit url value to reflect new bitbucket repository url
- mv projectname newprojectname
- 在 Bitbucket 项目设置中重命名项目
- vi projectname/.git/config 并编辑 url 值以反映新的 bitbucket 存储库 url
- mv 项目名称 新项目名称
回答by Rafal
You can rename the project form the settings menu of the projects on Bitbucket.
您可以在 Bitbucket 上项目的设置菜单中重命名项目。
Once you rename it, you need to update your git config file to fetch the data from the new location
重命名后,您需要更新 git 配置文件以从新位置获取数据
nano .git/config
Change the name of the project to the new name and save
将项目名称更改为新名称并保存
回答by frederickf
I think this is the easiest way:
我认为这是最简单的方法:
- Rename your project from the bitbucket settings menu
- Clone your newly re-named project
git clone new_url
- 从 bitbucket 设置菜单重命名您的项目
- 克隆您新重命名的项目
git clone new_url
This works because git is a distributed version control system. As far as git is concerned there is nothing special about the existing repo on your computer. Just clone a new one.
这是有效的,因为 git 是一个分布式版本控制系统。就 git 而言,您计算机上的现有存储库没有什么特别之处。只克隆一个新的。
If you prefer to keep using the existing local repo in my opinion it's easier to use git to update itself instead of manually editing a config file:
如果您更喜欢继续使用现有的本地存储库,我认为使用 git 更新自身比手动编辑配置文件更容易:
- Rename your project from the bitbucket settings menu
- Change directory into your local project and update git to fetch data from the newly renamed repo
git remote set-url origin new_url
- Optionally (git doesn't care) rename your local project directory
mv projectname newprojectname
- 从 bitbucket 设置菜单重命名您的项目
- 将目录更改为本地项目并更新 git 以从新重命名的 repo 中获取数据
git remote set-url origin new_url
- 可选(git 不关心)重命名您的本地项目目录
mv projectname newprojectname
回答by ferrangb
You can also do it in the BitBucket website.
您也可以在 BitBucket 网站上进行。
In your project page (https://bitbucket.org/username/yourproject), go to settings, repository details and then change the name and save it.
在您的项目页面 ( https://bitbucket.org/username/yourproject) 中,转到设置、存储库详细信息,然后更改名称并保存。
回答by Taras Chernata
To rename your bitbucket repo you can do 2 simple actions:
要重命名您的 bitbucket 存储库,您可以执行 2 个简单的操作:
- Rename your repository name in bitbucket repository settings(Your repository>Settings>Name field)
- (In case if you have the repository cloned to local machines) In project root directory go to .gitfolder, then open configfile. Change all the old repo names to new repo one.
- 在 bitbucket 存储库设置中重命名您的存储库名称(您的存储库>设置>名称字段)
- (如果您将存储库克隆到本地计算机)在项目根目录中转到.git文件夹,然后打开配置文件。将所有旧的回购名称更改为新的回购名称。