How do I do cross-domain redirects to github repositories from netlify?


I have a website on netlify ( with a
custom domain (, I want to link a github repo
to a route (for example GitHub - TruncatedDinosour/website: my website), I already achieved this
in the browser, it works fine and redirects to GitHub - TruncatedDinosour/website: my website but I would like it to be git-clonable, but it is not and anything
I found on it did not work (for example HTTP/302 redirect):

ari@ari-gentoo ~ % git clone
Cloning into 'git'...
fatal: repository '' not found

I have access to DNS and can add custom redirects and all that stuff,
just whatever netlify allows, you can see the /git route in website/netlify.toml at terminal · TruncatedDinosour/website · GitHub

    from = "/git"
    to = ""
    status = 301
    force = true

I found related stuff:

But they did not help

Is it even possible?

Hi @B00bleaTea

I would never have considered doing this, but it is.

I used _redirects (instead of netlify.toml)


I was then able to clone the repository locally.

So using the netlify.toml you would have

  from = "/git/*"
  to = ""
  status = 301
  # Not sure if force is really necessary
  force = true

The reason is that GitHub does a redirect too i.e.


so in order for the clone to work, you need to use a :splat to pass through the appended path.

The repository redirect blog post you linked to applies to internal redirects that GitHub does when a repository is renamed. The Stack Overflow thread, while seemingly related is related to git-server which doesn’t apply here.


Thank you!

I will try now :slight_smile:

It worked!

for example

ari@ari-gentoo tmp % git clone
Cloning into 'rys'...
warning: redirecting to
remote: Enumerating objects: 115, done.
remote: Counting objects: 100% (115/115), done.
remote: Compressing objects: 100% (58/58), done.
remote: Total 115 (delta 38), reused 105 (delta 28), pack-reused 0
Receiving objects: 100% (115/115), 27.79 KiB | 3.47 MiB/s, done.
Resolving deltas: 100% (38/38), done.

Thanks a lot :slight_smile: