Home > Software design >  git clone from redirect shorten url
git clone from redirect shorten url

Time:02-15

Following up from Git & redirections

I want to shorten my super long github gist http clone url with bitly (or any other url shorter), but I'm always getting repository not found. Is there any workaround for it please?

Basically, I know I need to make use of http.followRedirects, for my bit.ly links to my github url.
I did git config --global http.followRedirects true before doing git clone but
I'm still getting repository not found.

CodePudding user response:

This is explored in the Reddit thread "Does git-clone support http redirects?" and the author found that TinyURL works:

My understanding is that git clone should follow the redirect if httpfollowRedirects is not false. Actually, the URLs that end with .git give 301, as well as old URLs of repos that have been renamed. Not sure why shortened URLs don't work then. Because they reply 302 rather than 301?

Okay looks like it's indeed the case! I tried again with tinyurl which uses 301 instead 302 and it worked.

Both bitly and git.io use 302. git.io is created specifically for github URLs but the URLs it creates don't work with git

  • Related