Is this how GitHub Templates work?

Question: So let's say I create an empty folder in my local machine, run "npm init -y" in command line, and then run this command "npm create vite@latest", and with all this setup, I push this code into a GitHub Repo, and make it as a Template Repository, so next time I want to create a new project, under this "Template Repository" I click the "Use this template" button, and then "Create a new repository", I create a new repo from that template and clone it to my local machine. ( My question is, so now I don't have to run npm init -y and npm create vite@latest anymore? it's all just setup, with all the folders that I changed along the way etc... ? )
12 Replies
b1mind
b1mind•2y ago
So you would just clone it down or like I mentioned before you can use npx degit user/repo and then npm i it will use the lockfile if you include it in your template and install all the dep@version
Trazed
TrazedOP•2y ago
since im a beginner i think i will get confused with the degit part 🤣
b1mind
b1mind•2y ago
degit is a lib that just clones it without needing to be a template
Trazed
TrazedOP•2y ago
so by just doing a git clone <url> , everything will work just fine? oh alright
b1mind
b1mind•2y ago
you will still need to install the deps
Trazed
TrazedOP•2y ago
+ understood i just need to run npm i then that makes total sense thank you very much
b1mind
b1mind•2y ago
yup!
Trazed
TrazedOP•2y ago
so the degit lib will work for any repo thats the reason it exists gotcha šŸ˜„
b1mind
b1mind•2y ago
I mean it starts a fresh git history too I'm not sure with github template does? I've always just used degit haha Yea so like a Git template would bring all the branches too degit uses the last commit to main branch unless you specify the branch.
Trazed
TrazedOP•2y ago
lemme try this degit thing in desktop 🤣 i will be right back after uninstalling the os system
b1mind
b1mind•2y ago
you can just use npx too it just runs the lib without needing to install it npx degit user/repo
Trazed
TrazedOP•2y ago
npx degit user/repo <folder name> this is what i used and it worked just fine im really excited to learn these new stuff, it's just mindblowing to me as a junior and im loving it

Did you find this page helpful?