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
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@versionsince im a beginner i think i will get confused with the degit part
š¤£
degit is a lib that just clones it without needing to be a template
so by just doing a git clone <url> , everything will work just fine?
oh alright
you will still need to install the deps
+
understood
i just need to run npm i
then
that makes total sense
thank you very much
yup!
so the degit lib will work for any repo
thats the reason it exists
gotcha
š
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.
lemme try this degit thing in desktop
š¤£
i will be right back after uninstalling the os system
you can just use
npx
too
it just runs the lib without needing to install it
npx degit user/repo
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