degit: Error: "Could not find commit hash for master"
Hey there—I’m trying to get started with Svelte and running:
Environment:
- macOS 10.14 Mojave
- Node v8.11.4
- degit v2.1.3
Running:
degit sveltejs/template-webpack
… gives me:
! could not find commit hash for master
Double checking that the user/repo is correct, I’m not really sure why it can’t find the hash. I tried it with a couple other repos out there and no-go.
Any ideas?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 44
Setting the cache value to false in the degit options solved this for me:
Well derp, I was trying to run this on a new Macbook Pro that I hadn’t installed Xcode or the Command Line Tools on, so
gitwasn’t ready to go yet. Now that it’s installed, I trieddegitagain and everything worked like a charm.It may be pertinent in the rare cases when people don’t have
gitproperly configured (who even does that?!) thatdegitproperly pass any errors along that may occur like this.I run this “degit sveltejs/template my-svelte-project” on git terminal not the cmd … and it works . just right click then choose git bash here and run the command there . I hope that will be helpful .
I was just looking into getting degit to display more helpful error messages when it runs into a problem, and I found that it does display the underlying error if you call it with the verbose
-vflag. Does it make sense to always display that error? I’m hoping that will eliminate a lot of questions in Svelte issues and the chatroom about this. In the meantime, now that I know this, I suppose we can tell people to run it again with-vso we can get some sort of idea of what’s happening.Edit: Or perhaps less intrusively: a gentle extra note that’s displayed when there’s an error with verbose mode off that the user can add
-vto get more logging.I have
gitinstalled. Withcache: trueit attempts to find the repo from a local cache, which is what caused the error for me@paulocoghi
I know this thread is covering a lot of different issues now, but I had the same “could not fetch remote”:
but it turns out that my .gitconfig in my home directory had an invalid http proxy that I could no longer access. Hope this helps someone.
thanks @cogoo it worked !!
git update helped on windows 10
turns out the github repo is at
sveltejs/templatenotsvelte/templateand as such the command should benpx degit sveltejs/template <your-project-name>A PR adding a check to see which branch is available between
mainandmastercan solve the scenario mentioned by @netaisllc .Edit:
This PR (#243) from @fregante , provides an even better approach: read the default branch.
Note that Github itself has seemingly begun to default new repos to a
mainbranch.Today I ran into what looked like a
degitissue (! could not find commit hash for master) which actually wasn’tdegit’s problem. There indeed wasn’t amasterbranch. As soon as I created one and randegitagain there was much joy.@bernardoadc , you are right 👍 I had not thought about this possibility and, in this case, it is interesting that
degitusesgit.Since
gittaris a good alternative when all you want is to clone public repos, I believe that we have good options for any case.@masterl , unfortunately you are right.
As mentioned by @cogoo and @riazXrazor, when using degit on code (not as cli), setting
cachetofalseon the options may solve this problemBut it seems that we can’t do the same on cli.
@cogoo, in the most cases, this error occurs when
gitisn’t available/installed.