D
D
Denis2011-11-02 18:04:21
git
Denis, 2011-11-02 18:04:21

Git. Pull a specific file from the repository

Hello. How to pull a specific file or directory from a git repository without cloning the entire repository?

For example, the situation is this:
there is a local repository. It was corrected by hand and did not commit/delete/otherwise corrupt the file. There is a conflict when trying to do a git pull. Everything? Is life over? Need to re-clone the repository?

I saw this . But it doesn't work.

Deleted the index.html file in the local repository. I'm trying to restore: "test" is a comment to the commit with which the index.html file was launched into the repository. Tried with colon:

[email protected]:~/repos/projectname$ git show HEAD -- index.html
commit 7799d08a68166795f1fa33f4faf3435469439cd7
Author: Name Soname <[email protected]>
Date: Wed May 18 18:56:43 2011 +0400

test

diff --git a/index.html b/index.html
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/index.html
@@ -0,0 +1 @@
+test




[email protected]:~/repos/projectname$ git show HEAD:index.html
test

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Progrik, 2011-11-03
@Progrik

there is a local repository. It was corrected by hand and did not commit/delete/otherwise corrupt the file. There is a conflict when trying to do a git pull. Everything? Is life over? Need to re-clone the repository?

Perhaps the -f argument when running the command will help.
For example,
git pull -f
or
git push -f

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question