Skip to content

Instantly share code, notes, and snippets.

@dikiaap
Last active June 19, 2024 01:26
Show Gist options
  • Save dikiaap/01f5e2ba3c738012aef0a8f524a6e207 to your computer and use it in GitHub Desktop.
Save dikiaap/01f5e2ba3c738012aef0a8f524a6e207 to your computer and use it in GitHub Desktop.
git.io custom URL

Update: As of 11 January 2022, git.io no longer accepts new URLs.

Command:

curl https://git.io/ -i -F "url=https://github.com/YOUR_GITHUB_URL" -F "code=YOUR_CUSTOM_NAME"

URLs that can be created is from:

  • https://github.com/*
  • https://*.github.com
  • https://*.github.com/*
  • https://*.github.io
  • https://*.github.io/*
  • https://*.githubusercontent.com/*

If you accidentally make a typo in the custom name, you can add .git (only the repository name) or ? at the end in your GitHub URL.

curl https://git.io/ -i -F "url=https://github.com/YOUR_GITHUB_URL.git" -F "code=YOUR_CUSTOM_NAME"
curl https://git.io/ -i -F "url=https://github.com/YOUR_GITHUB_URL?" -F "code=YOUR_CUSTOM_NAME"

Shortcut to this Gist: git.io/customurl

@sortalost
Copy link

Those Who all are trying to shorten their USERNAME.github.io/REPO link, If y'all face any errors,

  1. Then don't do the .git hack suggested by @koumaza here.

  2. Change your repo name a bit, and then try the same thing.

$ curl https://git.io/ -i -F "url=https://USERNAME.github.io/NEW_REPO_NAME" -F "code=CUSTOM_NAME"

@pavi2410
Copy link

pavi2410 commented Aug 10, 2021

I created an alias in gh cli like so

> gh alias set --shell gitio 'curl.exe https://git.io/ -i -F "url=$1" -F "code=$2"'

Note: On Linux, replace curl.exe with curl

Use it as shown below

> gh gitio https://gist.github.com/4b6201bd19e5f5cc0349492af0b8ee28 tcp_echo_server_client
HTTP/1.1 201 Created
Server: Cowboy
Connection: keep-alive
Date: Tue, 10 Aug 2021 12:40:59 GMT
Status: 201 Created
Content-Type: text/html;charset=utf-8
Location: https://git.io/tcp_echo_server_client
Content-Length: 56
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Runtime: 0.006904
X-Node: 80a0b9ab-c56e-4039-a069-24e6cc1404c6
X-Revision: 392798d237fc1aa5cd55cada10d2945773e741a8
Strict-Transport-Security: max-age=31536000; includeSubDomains
Via: 1.1 vegur

https://gist.github.com/4b6201bd19e5f5cc0349492af0b8ee28

@nskobelevs
Copy link

nskobelevs commented Sep 1, 2021

Lovely stuff!

Although git.io/customrul doesn't work anymore :(

Redirects to https://gist.github.com/dikiaap/01f5e2ba3c738012aef0a8f524a6e207%5C#file-git-io-custom-url-md but with a Page Not Found.

Doesn't seem to like the backslash (%5C) as removing that works grand.

Made www.git.io/custom-url as a fix!

@asheroto
Copy link

asheroto commented Oct 20, 2021

Apparently you can't visit the shortened URL before you create it. If you do, it may not work.

I created a custom shortened URL but visited the URL first, and even after creating it, it said "no url found". Thought it might just be a cached/cdn issue, so waited a few days. It still didn't work after a few days.

Ended up just added a ? to fix.

@hosamn
Copy link

hosamn commented Feb 2, 2022

Update: As of 11 January 2022, git.io no longer accepts new URLs.
Any Idea why they did this?
the blog post gives no explations at all :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment