Scaffolding a new project based on the existing git template repository

Jun 3, 2022
Learn how to scaffold a new project based on the existing git template repository to scaffold
As a developer in this open-source era, we often try to explore libraries/frameworks/project codebases and mostly starter template for kick starting personal projects. The most common way is to clone the repository using the git clone CLI command.
notion image
But cloning a repository will download its entire git history with all the branch details which are not needed and it takes time to clone it as well.
So how can we quickly download a GitHub repository?
Well, there are a couple of ways we can do it,
  1. Download as a zip file via GUI
The easiest way from GUI. The zip file will be downloaded without git version control. We can then unzip and start working on it.
Here we won't be able to download specific folders.
  1. git clone --depth 1
With this method, we will be cloning the repository with only the last commit. This will be faster than the clone command without any args. Let's say if we are cloning a project template we don't want the template's git history or certain files like license, etc.
It would be inconvenient for us to do re-init git and reset origin remote pointer and mostly we are likely to forget doing those due to the project's excitement.
  1. Via degit
degit is a cooler way of cloning a project from a remote repository if you are a keyboard user. It majorly supports Github/GitLab/BitBucket/Sourcehut.
We can globally install or run the commands using npx.
To create a new folder for the project.
By default master branch will be cloned. We can even clone based on a tag, branch, or a commit
Here comes the coolest part, we can clone only a specific folder instead of downloading the entire repository 🤩
It also provides additional features like executing post scripts that helps us to run commands like
How this is different from the 2nd solution? Author's Rich Harris Reply here
Alternative - zel
Happy solving!


© Bharathvaj Ganesan 2020 - 2023