如何重命名使用 gitolite 创建的 Git 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4708465/
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
How do I rename a Git repository created with gitolite?
提问by Patrick
I created a Git repository using gitolite. Now I would like to rename that repository.
我使用 gitolite 创建了一个 Git 存储库。现在我想重命名该存储库。
How can I do this?
我怎样才能做到这一点?
In gitolite's readme is says that I should not work directly on the server. But I guess I have to do some work on the server in this case, right?
在 gitolite 的自述文件中说我不应该直接在服务器上工作。但是我想在这种情况下我必须在服务器上做一些工作,对吗?
回答by takeshin
As stated in the gitolite basic-admin manual:
renaming a repo
重命名回购
This is similar; there's no code to do this in gitolite
. What you do is:
这很相似;没有代码可以做到这一点gitolite
。你要做的是:
log on to the server,
cd $REPO_BASE
(default:cd ~/repositories
), andmv old-name.git new-name.git
back on your gitolite-admin clone, edit
conf/gitolite.conf
and replace all occurrences ofold-name
withnew-name
. Then add, commit, and push as usual.
登录到服务器,
cd $REPO_BASE
(默认:)cd ~/repositories
,和mv old-name.git new-name.git
回到您的 gitolite-admin 克隆,编辑
conf/gitolite.conf
并替换所有出现的old-name
withnew-name
。然后像往常一样添加、提交和推送。
The order of these 2 steps is important; do not reverse them :-)
这两个步骤的顺序很重要;不要颠倒它们:-)
A third step is necessary on gitolite3:
在 gitolite3 上需要第三步:
- edit file
gl-conf
in the repo and change the repository name to the new name
- 编辑
gl-conf
repo 中的文件并将存储库名称更改为新名称
And of course, every user should update his clone configuration to point to the new repo name.
当然,每个用户都应该更新他的克隆配置以指向新的存储库名称。
回答by Greg Hewgill
I'm not familiar with gitolite specifically, but one approach that might work is to create a completely new repository with the correct name, push your code up into that one, and then delete the old one.
我对 gitolite 并不特别熟悉,但一种可行的方法是创建一个具有正确名称的全新存储库,将您的代码推送到该存储库中,然后删除旧存储库。
回答by Greg Hewgill
Using Greg Hewgill as an idea, you possibly can rename the repository in the config file. You may want to try that on a dummy repository first. My suspicions is the old name will be deleted, the new will be created and you need to update your origins locally then push.
使用 Greg Hewgill 作为一个想法,您可以重命名配置文件中的存储库。您可能想先在虚拟存储库上尝试。我怀疑旧名称将被删除,新名称将被创建,您需要在本地更新您的来源然后推送。
回答by V13
A clean approach is to create the new repository as an empty one, then do the following:
一种干净的方法是将新存储库创建为空存储库,然后执行以下操作:
Assuming old is OLD and new (empty) is NEW:
假设旧的是旧的,新的(空的)是新的:
# mkdir /tmp/1
# cd /tmp/1
# git clone OLD_REPO old
# git clone NEW_REPO new
# cd new
# git pull ../old
# git push origin master
Or you can use directly the remote repo for OLD:
或者您可以直接使用 OLD 的远程仓库:
# mkdir /tmp/1
# cd /tmp/1
# git clone NEW_REPO new
# cd new
# git pull OLD_REPO
# git push origin master
This will keep all history and will let gitolite handle its internals. Additionally you'll have to update gitolite-admin but there's not limitation in the order.
这将保留所有历史记录,并让 gitolite 处理其内部结构。此外,您必须更新 gitolite-admin,但顺序没有限制。
This also works remotely without problems.
这也可以毫无问题地远程工作。
Deleting the OLD repository should be done per gitolite's instructions (locally) though.
不过,应该按照 gitolite 的说明(本地)删除 OLD 存储库。