I have a git repository named demo.In that git i have a file named details.This details file contains some filenames listed in it.My requirement is that when i checkout the repository, I want only the files whose names are in details file to be pulled and other files shouldn't be checked out.I have tried sparse checkout , but sparse checkout helps to pull files of a sub directory in a repository while my need is that the files which are listed in details file alone should be checked out.Could you suggest me ways to do it?
Asked
Active
Viewed 165 times
1
-
Seems like you're trying to reinvent `.gitignore`, which exists for this kind of things but works the opposite way : listed files are (as in the name) ignored from git track kist. Could it achieve what you want ? (might depend on your directory structure) – Romain Valeri Jun 28 '18 at 12:07
-
@RomainVALERI .gitignore performs the option while check in rite that is during push ,i want the same operation during checkout from repo. – Mridula Sivanandan Reddy Jun 29 '18 at 07:03
1 Answers
0
You could do a git clone -n
to avoid any checkout.
Then you would checkout only the "details" file.
Finally, with Git 2.25 (Q1 2020), you actually can use that file to checkout only the paths specified in it.
See git checkout --pathspec-from-file=<file>
: it will read the content of the file and check out only said content.

VonC
- 1,262,500
- 529
- 4,410
- 5,250