3 ms·
I don't think that's possible. You'd have to `git init`, `git remote add ...`, `git fetch --depth 1 MYREMOTE MYCOMMIT`. If this is a frequent case for you, you
by chronial 9y ago
I don't think that's possible. You'd have to `git init`, `git remote add ...`, `git fetch --depth 1 MYREMOTE MYCOMMIT`.
If this is a frequent case for you, you could easily add an alias for this.
- Ace17 9y ago$ git init Initialized empty Git repository in /tmp/phobos/.git/ $ git remote add origin https://github.com/dlang/phobos.git https://github.com/dlang/phobos.git $ git fetch --depth=1 origin 6e5cdacfa6ac018c6ef42aa9679893676f293f21 error: no such remote ref 6e5cdacfa6ac018c6ef42aa9679893676f293f21 However, the commit exists: $ git fetch --depth=1000 [... a long time after ...] $ git checkout 6e5cdacfa6ac018c6ef42aa9679893676f293f21 Note: checking out '6e5cdacfa6ac018c6ef42aa9679893676f293f21'. [...] HEAD is now at 6e5cdacf... phobos 0.2
- chronial 9y agoThis looks like github configuration. My (probably newer) git tells me: $ git fetch --depth=1 origin 6e5cdacfa6ac018c6ef42aa9679893676f293f21 error: Server does not allow request for unadvertised object 6e5cdacfa6ac018c6ef42aa9679893676f293f21 Note that this works fine and has the same effect: $ git fetch --depth=1 origin phobos-0.2 If you want the first command to work, you will probably have to host somewhere other than github.
- Ace17 9y ago> This looks like github configuration This also doesn't work on gitlab. $ git clone -q --depth=10 https://gitlab.com/fdroid/fdroidclient.git https://gitlab.com/fdroid/fdroidclient.git $ cd fdroidclient $ git fetch --depth=1 origin 5d2c2bc6e636e40eee80c59d1de6c1eff0ba4472 error: no such remote ref 5d2c2bc6e636e40eee80c59d1de6c1eff0ba4472 $ git fetch -q --depth=200 $ git checkout 5d2c2bc6e636e40eee80c59d1de6c1eff0ba4472 Note: checking out '5d2c2bc6e636e40eee80c59d1de6c1eff0ba4472'. [...] HEAD is now at 5d2c2bc... Merge branch 'fix-npe-verifying-perms' into 'master' Please be honest: did you see it work at least once? > If you want the first command to work, you will probably have to host somewhere other than github Please keep in mind that those are generally third party projects. Convincing all the maintainers to move away from github is going to be hard. It seems we're back to square one.
- chronial 9y ago> Please be honest: did you see it work at least once? No, I never tried this before. I was just guessing based on the client error message. But a quick look in the source reveals that this is indeed a server setting that defaults to false: https://git-scm.com/docs/git-config#git-config-uploadpackallowReachableSHA1InWant https://git-scm.com/docs/git-config#git-config-uploadpackall... If fetching non-tagged, non-branchhead commits is actually a frequent use case for you, you could ask github whether they might change their config. You are not the first person to want this: https://github.com/isaacs/github/issues/436 https://github.com/isaacs/github/issues/436 > It seems we're back to square one. Almost :). You said: > Bazaars allows remotely fetching one single revision from a repo, without requiring to download the whole history. You can't do this with git. As it turns out that is not correct – git can absolutely do that. But the two biggest hosters don't allow it.
- Ace17 9y agoExtract from the pages you linked: "However, note that calculating object reachability is computationally expensive. Defaults to false." "it is off by default and generally advised against on performance reasons." > > Bazaars allows remotely fetching one single revision from a repo, without requiring to download the whole history. You can't do this with git. > As it turns out that is not correct – git can absolutely do that. But the two biggest hosters don't allow it. I stand corrected, I should have written instead: "git designs makes this operation so expensive that git disables it by default, which means you can't use it with github and gitlab, and probably the vast majority of git servers in the world, making it unusable in practice". > you could ask github whether they might change their config. Yeah, right.