Search
⌘K
    to navigateEnterto select Escto close

    Hit y before copying url from github

    Let's say that I'm writing a blog and I need to link to a newly added file. I can link to that file by going to github and copying the url. However a few months later that file might have moved to a different directory and now the link is broken.

    Github team created a shortcut to solve this problem. Just hit y on your keyboard before copying the url.

    Here is an example.

    Let's say that I am linking to newly created rake_proxy.rb file in Rails 5. If I go to the file in master and copy the url then url looks like as shown below.

    1https://github.com/rails/rails/blob/master/railties/lib/rails/commands/rake_proxy.rb

    As you can see the url is pointing file in master branch. As stated above the problem is that this link is pointing to live master branch and if a few months later this file is moved to some other place then link will be broken.

    Now let's see what happens when I hit y on my keyboard. The url will change to as shown below.

    1https://github.com/rails/rails/blob/f718e52bcce02bc137263ead3a9d9f5df1c42c37/railties/lib/rails/commands/rake_proxy.rb

    This url is pointing to a blob and not to master branch. This URL will always work.

    Previous
    Next