Neik
Neik

Reputation: 43

git: checkout or checkout-index a directory with a different name

I would like to checkout a directory, and its contents, from an earlier commit into the working directory under another name; or alternatively into another directory under the same name.

It's a bit like checking out a temp file, but I need a whole directory and I don't want to overwrite the existing one.

Upvotes: 1

Views: 479

Answers (1)

Joseph K. Strauss
Joseph K. Strauss

Reputation: 4903

Look at http://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging for more on this. In your situation, though, you will probably want to do the following:

 git read-tree -u --prefix=<temp-location>/ <old-commit>:<path/to/dir>

Upvotes: 1

Related Questions