简体   繁体   中英

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. 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 clone test new_test

new_test will now contain the .git directory and a working copy. Alternatively, you can also point directly to the .git directory:

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.

It is normally produced on stdout, so you can simply run 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.

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. 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 ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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