如何在没有在git中的本地机器中重新克隆的情况下将远程非裸存储转换为裸reopos?

时间:2022-12-13 21:46:45

I have a remote machine RemoteMachine which hold the clone of another MachineWeNotConcern with:

我有一个远程机器RemoteMachine,其中包含另一个MachineWeNotConcern的克隆:

git clone MachineWeNotConcern/prj prj

My local machine clone like this:

我的本地机器克隆如下:

git clone RemoteMachine/prj local_prj

Now I want to make the RemoteMachine's repos to bare(how?) as if I checked with:

现在我想将RemoteMachine的repos设置为裸(如何?),就好像我检查过:

git clone --bare MachineWeNotConcern/prj prj

And I don't want to re-clone from my bare repos of the RemoteMachine because it always takes to much time.

而且我不想从我裸露的RemoteMachine回购中重新克隆,因为它总是花费很多时间。

How can I achieve this?

我怎样才能做到这一点?

1 个解决方案

#1


You could make a new clone from your local repo on the remote machine of the project with --bare. ie:

您可以使用--bare从项目的远程计算机上的本地存储库中创建新的克隆。即:

git clone --bare prj bare_prj

Then delete the original prj. This would be faster than cloning it from the original machine again.

然后删除原始prj。这比再次从原始机器克隆它要快。

EDIT: Another solution:

编辑:另一种解决方案:

It looks like you could make your repo into a bare repo by:

看起来您可以通过以下方式将您的仓库变成一个裸仓库:

  • changing the .git/config file to have bare = true instead of bare = false
  • 将.git / config文件更改为bare = true而不是bare = false

  • removing the contents of prj/* other than the .git file
  • 删除除.git文件以外的prj / *的内容

  • moving the .git dir contents into prj/ and removing the .git dir
  • 将.git目录内容移动到prj /并删除.git目录

At least, this seems to work for me, but there could be reasons this would fail, for all I know.

至少,这似乎对我有用,但可能有理由这会失败,因为我所知道的一切。

#1


You could make a new clone from your local repo on the remote machine of the project with --bare. ie:

您可以使用--bare从项目的远程计算机上的本地存储库中创建新的克隆。即:

git clone --bare prj bare_prj

Then delete the original prj. This would be faster than cloning it from the original machine again.

然后删除原始prj。这比再次从原始机器克隆它要快。

EDIT: Another solution:

编辑:另一种解决方案:

It looks like you could make your repo into a bare repo by:

看起来您可以通过以下方式将您的仓库变成一个裸仓库:

  • changing the .git/config file to have bare = true instead of bare = false
  • 将.git / config文件更改为bare = true而不是bare = false

  • removing the contents of prj/* other than the .git file
  • 删除除.git文件以外的prj / *的内容

  • moving the .git dir contents into prj/ and removing the .git dir
  • 将.git目录内容移动到prj /并删除.git目录

At least, this seems to work for me, but there could be reasons this would fail, for all I know.

至少,这似乎对我有用,但可能有理由这会失败,因为我所知道的一切。