Creating working directory files from a .git directory

I have a .git directory, but I don't have the actual working directory, just a repo. Which command can I use to recreate the working directory?

+4
source share
3 answers

Let's say that .git-dir is in an empty directory, otherwise called "test."

 git clone test new_test 

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

 git clone test/.git new_test 

with the same result.

+6
source

I think you are really asking how to make a bare repository open. Although this is probably the easiest to repeat, this also works:

First, make sure that all internal git files (e.g. index, HEAD) and folders (e.g. hooks, info, objects, refs) are in a folder named .git. This is probably not the case now that your repository is still bare. So just rename it. Then move this to the folder in which you want to become the working directory.

And then at the working directory level:

 git config core.bare 0 git checkout -f 

However, it's easier to just clone again; -)

+1
source

If you need not a working repository to work, but just a copy of the working files, you can run git archive in the .git directory to generate a tar file from the working tree.

It is usually created on stdout, so you can just run git --git-dir=/path/to/repo archive | tar x git --git-dir=/path/to/repo archive | tar x to get a copy in the working directory.

0
source

All Articles