Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create redirects for moved files in a github repository?

I'm reorganizing a collection of documentation that is hosted as a github repository. Is there any way to create redirects in the repository so that anyone who has bookmarked a file that has moved is redirected to the new location?

like image 842
Orian Marx Avatar asked Nov 13 '22 17:11

Orian Marx


1 Answers

I am not aware of any way to set up redirects for moved files. The next best thing to do depends on what you need?

  • Do you just want to avoid broken URLs? Then distribute URLs that are more permanent. One way of doing that is locating the file you want to link to on GitHub, then pressing y which will replace the branch name with a commit SHA. For example, if you're at https://github.com/fred/frobbler/blob/master/LICENSE.md and then press y, you're browser will reload https://github.com/fred/frobbler/blob/{commit-sha}/LICENSE.md. Even if LICENSE.md were removed or renamed in later commits, that URL will stay valid. Of course, people will now be linked to a particular (historic) snapshot of that file.

  • Do you want to forward people to the latest version of the previous content? In that case, you'll likely need to keep the old document around and put a notice in it where the new document can be found. Or, you use one of those URL abbreviation services to generate a public URL, which allows you to edit the actual URL later on.

like image 57
stakx - no longer contributing Avatar answered Nov 15 '22 08:11

stakx - no longer contributing