Search code examples
gitgit-checkoutworking-directory

It there a built in Git command for checking out a Git ref or branch into a non git directory?


I am compiling source from a local git mirror in a separate directory, ie I don't do any work in the Git directory, I just need the source code from it.

Of course I go into the Git directory, check out the ref I want and copy it into the compilation directory, but I want to know if there is a git command for doing it directly

Something along the lines of:

git checkout file://home/user/repo.get treeish  /my/working/directory

Solution

  • I don't know a command which can extract a tree from the repository, but the git archive command can create a tarball (or other format) of the tree at a given commit:

    git archive --format=tar <commit-id> > project.tar