1

While pushing files to Github, we can ignore files from the Git repo. Can we ignore files while downloading from Github? There are YAML, CONTRIBUTION, CODE_OF_CONDUCT, etc files in Github that we don't want to download from Github while cloning the repo.

Naveed Hematmal
  • 343
  • 4
  • 17
  • 1
    Not exactly an answer to your specific question, but check it out: https://stackoverflow.com/questions/14326365/git-clone-ignoring-a-directory – Anton Apr 29 '20 at 20:35
  • *While we are pushing files to Github, we can ignore files in git.* No, you can't: what you can push to GitHub are *commits*, not files. The commits have files, or don't have them. That's all there is to it. Note that if you clone a *repository* from GitHub, you get *commits*, not files, again. You can, if you prefer, use GitHub's "download an archive of one specific commit" feature, to get one specific tar or zip archive. – torek Apr 29 '20 at 21:37

1 Answers1

1

You can do a partial clone, which is stricter than a sparse checkout:

  • a sparse checkout means: you clone everything but restore only some files in the working tree.
  • a partial clone means: you clone only what you need (then restore everything cloned in the working tree)

The partial clone uses a git rev-list --filter option.

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