简体   繁体   English

从.git目录生成工作目录文件

[英]Generate the working directory files from .git directory

I have the .git directory, but I do not have the actual working directory, just the repo. 我有.git目录,但我没有实际的工作目录,只有repo。 What command can I use to recreate the working directory? 我可以使用什么命令重新创建工作目录?

Let's say the .git dir is in an otherwise empty directory called "test." 假设.git目录位于另一个名为“test”的空目录中。

git clone test new_test

new_test will now contain the .git directory and a working copy. new_test现在将包含.git目录和工作副本。 Alternatively, you can also point directly to the .git directory: 或者,您也可以直接指向.git目录:

git clone test/.git new_test

with the same result. 结果相同。

If what you need is not a working repository to work with, but merely a copy of the working files, you can run git archive on the .git directory to generate a Tar file from the working tree. 如果您需要的不是可以使用的工作存储库,而只是工作文件的副本,则可以在.git目录上运行git archive以从工作树生成Tar文件。

It is normally produced on stdout, so you can simply run git --git-dir=/path/to/repo archive | tar x 它通常在stdout上生成,所以你可以简单地运行git --git-dir=/path/to/repo archive | tar x git --git-dir=/path/to/repo archive | tar x to get a copy in your working directory. git --git-dir=/path/to/repo archive | tar x在工作目录中获取副本。

I think you are actually asking how to make a bare repository non bare. 我想你实际上是在询问如何制作一个裸机库。 While it is probably the easiest just to clone it again, this also works: 虽然它可能是最简单的再次克隆它,这也有效:

First make sure that all the internal git files (eg index, HEAD) and folders (eg hooks, info, objects, refs) are in a folder named .git. 首先确保所有内部git文件(例如索引,HEAD)和文件夹(例如钩子,信息,对象,引用)都在名为.git的文件夹中。 That's probably not the case now that your repository is still bare. 现在可能不是您的存储库仍然裸露的情况。 So just rename it. 所以只需将其重命名即可。 Then move that into the folder that you want to become your working directory. 然后将其移动到要成为工作目录的文件夹中。

And then on the working directory level: 然后在工作目录级别:

git config core.bare 0
git checkout -f

However, it's more easy to just clone again ;-) 但是,再次克隆更容易;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM