Cloning a Single File from a Git Repository

history edit

Git

  1. git init
  2. git remote add origin <remote-uri>
  3. git sparse-checkout set 1
  4. git sparse-checkout add <file-path>
  5. git fetch origin main 2
  6. git checkout main
  1. This is a simpler sparse initialisation, but includes more files by default. 

  2. This will, still, download the complete repo history.