0

When I am trying to clone a public repository I am getting below error

fatal: repository 'https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs.git/' not found.

I am trying to clone the following URL

https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs.git/

instead of copying the repository

https://github.com/kubernetes/examples.git

I do not want to copy entire repository as there are lots of files. The necessary part is available on "staging/volumes/nfs".

will it work or do I have to copy the repository itself?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • You can choose which files to include when cloning a repository, see https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934. – Jan Morawiec Aug 30 '23 at 11:06
  • You should change your question title to *what you want to achieve* (i.e. cloning only a subdirectory of a git repo), instead of just the error message. – Fritz Aug 30 '23 at 11:08
  • @Frizt edited my question title as suggested. – Kubespecial Aug 30 '23 at 11:34

1 Answers1

0

A subfolder inside a git repository is not a git repository itself. You have to clone the top level repository, because it contains the (hidden) .git folder, which is the actual repository containing the commit history etc.

What you want is a sparse checkout: https://stackoverflow.com/a/60729017/1221661

Fritz
  • 1,293
  • 15
  • 27