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ā€¢13mo 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
Harun
HarunOPā€¢13mo ago
since im a beginner i think i will get confused with the degit part šŸ¤£
b1mind
b1mindā€¢13mo ago
degit is a lib that just clones it without needing to be a template
Harun
HarunOPā€¢13mo ago
so by just doing a git clone <url> , everything will work just fine? oh alright
b1mind
b1mindā€¢13mo ago
you will still need to install the deps
Harun
HarunOPā€¢13mo ago
+ understood i just need to run npm i then that makes total sense thank you very much
b1mind
b1mindā€¢13mo ago
yup!
Harun
HarunOPā€¢13mo ago
so the degit lib will work for any repo thats the reason it exists gotcha šŸ˜„
b1mind
b1mindā€¢13mo 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.
Harun
HarunOPā€¢13mo ago
lemme try this degit thing in desktop šŸ¤£ i will be right back after uninstalling the os system
b1mind
b1mindā€¢13mo ago
you can just use npx too it just runs the lib without needing to install it npx degit user/repo
Harun
HarunOPā€¢13mo 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
Want results from more Discord servers?
Add your server