Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to copy a SINGLE FILE from LOCAL REPOSITORY to my machine, not git-pull or git-fetch, how can i do it?

Is it possible to get it via hash ? such as a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef ?

share|improve this question
2  
If the repository is local, just cp unless it's a bare repo. –  jordanm Oct 24 '13 at 4:39

1 Answer 1

up vote 6 down vote accepted

You can use git archive to obtain a single file from a repository:

git archive --remote=file:///path/to/repository.git HEAD:path/to/directory filename | tar -x

The repository specified as --remote can be local, remote, bare or regular, it works in all of the aforementioned cases.

Note that if you want to obtain a version of filename from a specific commit, you can replace HEAD in the oneliner above with the hash of the desired commit.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.