# Git-style repo cloning doesn't work

**URL:** <https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007>\
**Category:** Help\
**Tags:** go-ipfs\
**Created:** [April 22, 2021, 12:35pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007 "2021-04-22T12:35:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![barnus11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/barnus11/32/4942_2.png) [@barnus11](https://discuss.ipfs.tech/u/barnus11)\
**Post date:** [April 22, 2021, 12:35pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/1 "2021-04-22T12:35:52Z")

</div>

Hello all!

I’ve followed the tutorial on hosting a git-style repository on ipfs, however when I try to clone the repo with the given command (`git clone http://QmX679gmfyaRkKMvPA4WGNWXj9PtpvKWGPgtXaF18etC95.ipfs.localhost:8080/ myrepo`)  
it doesn’t seem to work. I get a fatal error and git says it is `unable to resolve the host QmX679gmfyaRkKMvPA4WGNWXj9PtpvKWGPgtXaF18etC95.ipfs.localhost`.  
What am I doing wrong? Or is there a configuration step before I can follow this tutorial that I might’ve missed?

I set up the ipfs node with init and then ran the daemon. Everything else I did is in the [Store & play videos | IPFS Docs](https://docs.ipfs.io/how-to/store-play-videos/) tutorial.

Thanks for the help in advance!

---

<div class="post-metadata">

**Author:** ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)\
**Post date:** [April 22, 2021, 12:39pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/2 "2021-04-22T12:39:59Z")

</div>

On quick glance I believe you need a base32 encoded CID to use the subdomain gateways.

Try `http://bafybeieb75o7544uiy4yjl3bhyy3xlevxtwsczkwktflrgqs2n6xjjahba.ipfs.localhost:8080/myrepo`

You can use `ipfs cid format -b base32 -v 1 QmX679gmfyaRkKMvPA4WGNWXj9PtpvKWGPgtXaF18etC95` to convert your v0 CID to a v1 CID using base32.

[Anatomy of a CID](https://proto.school/anatomy-of-a-cid) might be useful if you’re looking to know more about how CIDs work 🙂 .

Edit: That doc you linked should probably be updated for subdomain gateways.

---

<div class="post-metadata">

**Author:** ![barnus11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/barnus11/32/4942_2.png) [@barnus11](https://discuss.ipfs.tech/u/barnus11)\
**Post date:** [April 22, 2021, 1:15pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/3 "2021-04-22T13:15:13Z")

</div>

Thanks for the quick reply!

I tried to convert it the way you showed, but I still get the error. It can’t seem to find it, even though I can get it in my browser no problem. Anything else I could try to look into, that might help? 😃

I’m gonna look at [https://proto.school/anatomy-of-a-cid](https://proto.school/anatomy-of-a-cid) !

---

<div class="post-metadata">

**Author:** ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)\
**Post date:** [April 22, 2021, 1:24pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/4 "2021-04-22T13:24:59Z")

</div>

I find it strange that it’s unable to resolve localhost! Glad it’s working in the browser, but I’m not sure why your terminal doesn’t want to resolve localhost :S. Do you maybe have a git configuration that could be interfering?

For example, I can’t even get “unable to resolve host” even with `git clone http://this.isnot.valid.localhost`.

I’m glad the tutorial is of interest 🙂, I found it helpful for learning about how CIDs are made.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [April 22, 2021, 1:35pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/5 "2021-04-22T13:35:12Z")

</div>

> [@barnus11](#):
>
> It can’t seem to find it, even though I can get it in my browser no problem

Browsers have magic to resolve these localhost-subdomains. Try `http://localhost:8080/ipfs/bafybeieb75o7544uiy4yjl3bhyy3xlevxtwsczkwktflrgqs2n6xjjahba/myrepo` instead.

---

<div class="post-metadata">

**Author:** ![barnus11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/barnus11/32/4942_2.png) [@barnus11](https://discuss.ipfs.tech/u/barnus11)\
**Post date:** [April 22, 2021, 1:38pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/6 "2021-04-22T13:38:55Z")

</div>

I tried that as well, and this is what I get:

```auto
git clone http://localhost:8080/ipfs/$hash$ somefolder
Cloning into 'somefolder'...
fatal: unable to access 'http://localhost:8080/ipfs/$hash$/': Could not resolve host: $hash$.ipfs.localhost

```

I have no clue what the problem could be, I’m too new to IPFS as a whole.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [April 22, 2021, 2:24pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/7 "2021-04-22T14:24:38Z")

</div>

Check if you have configured your IPFS gateway as a subdomain gateway (UseSubdomains: true). I don’t think it should be redirecting to the `<cid>.ipfs.localhost` url by default.

---

<div class="post-metadata">

**Author:** ![barnus11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/barnus11/32/4942_2.png) [@barnus11](https://discuss.ipfs.tech/u/barnus11)\
**Post date:** [April 22, 2021, 2:34pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/9 "2021-04-22T14:34:58Z")

</div>

It isn’t as far as I can see:

```json
"Gateway": {
    "APICommands": [],
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With",
        "Range",
        "User-Agent"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "NoDNSLink": false,
    "NoFetch": false,
    "PathPrefixes": [],
    "PublicGateways": null,
    "RootRedirect": "",
    "Writable": false
  }

```

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [April 22, 2021, 3:00pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/10 "2021-04-22T15:00:11Z")

</div>

@lidel help! Do you know why this happens?

---

<div class="post-metadata">

**Author:** ![lidel](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lidel/32/9853_2.png) [@lidel](https://discuss.ipfs.tech/u/lidel)\
**Post date:** [April 22, 2021, 4:36pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/11 "2021-04-22T16:36:08Z")

</div>

Hi friends, this is a fun one, but there are various ways of fixing this on CLI:

- **TLDR fix** : use loopback IP (`127.0.0.1`) instead of DNS name (`localhost`):

- alternative global fix: configure your OS (assuming Linux?) to support subdomains on localhost (eg. via [nss-myhostname](https://github.com/ipfs/go-ipfs/issues/7290#issuecomment-813555203))

- alternative ad-hoc fix: use go-ipfs as HTTP proxy (`export HTTP_PROXY=http://127.0.0.1:8080`). Caveat: it only resolves IPFS resources over HTTP (localhost gateway), you won’t be able to browse the regular web with this.

When in hurry, just do the TLDR one.

Explainer:

- `localhost` gateway is a [subdomain gateway](https://docs.ipfs.io/how-to/address-ipfs-on-web/#subdomain-gateway) that redirects requests for `/path/{cid}` to a `{cid}.ipfs.localhost` DNS name

- subdomain gateways like this are useful in browser context because they provide [Origin-based isolation per root CID](https://en.wikipedia.org/wiki/Same-origin_policy)

- [browsers hardcode `localhost` and its subdomains to the loopback device](https://bugzilla.mozilla.org/show_bug.cgi?id=1220810) (security feature), but if you use other software, the DNS resolver from your OS is used for resolving `*.localhost` names, and that is a known problem when using CLI tools on some Linux boxes: [gateway subdomains: \*.localhost not found · Issue #7290 · ipfs/go-ipfs · GitHub](https://github.com/ipfs/go-ipfs/issues/7290)

- before it was hardcoded in browsers, we used HTTP proxy mode for avoiding DNS lookups; this is still supported

- one can use regular [path gateway](https://docs.ipfs.io/how-to/address-ipfs-on-web/#path-gateway) on local machine by using `127.0.0.1:8080` endpoint

- subdomain isolation does not provide any value outside of browser, so no reason to use `localhost` for git use case – just use `127.0.0.1` and the problem will go away

---

<div class="post-metadata">

**Author:** ![barnus11](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/barnus11/32/4942_2.png) [@barnus11](https://discuss.ipfs.tech/u/barnus11)\
**Post date:** [April 22, 2021, 5:56pm UTC](https://discuss.ipfs.tech/t/git-style-repo-cloning-doesnt-work/11007/12 "2021-04-22T17:56:39Z")

</div>

I’m on a windows machine, so I didn’t test the subdomain solution, though I might try it, if there is a way to do it on win10 as well. But the TLDR version solved it!
