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
?
git
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
?
Best Answer
You can use
git archive
to obtain a single file from a repository: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 replaceHEAD
in the oneliner above with the hash of the desired commit.