How to link to specific line number on github

后端 未结 7 693
滥情空心
滥情空心 2020-11-28 00:57

I know I can link to a specific line number on a file on a github repo (I\'m sure I\'ve seen this before)...

Can someone tell me how to do this?

7条回答
  •  余生分开走
    2020-11-28 01:06

    Related to how to link to the README.md of a GitHub repository to a specific line number of code

    You have three cases:

    1. We can link to (custom commit)

      But Link will ALWAYS link to old file version, which will NOT contains new updates in the master branch for example. Example:

      https://github.com/username/projectname/blob/b8d94367354011a0470f1b73c8f135f095e28dd4/file.txt#L10
      
    2. We can link to (custom branch) like (master-branch). But the link will ALWAYS link to the latest file version which will contain new updates. Due to new updates, the link may point to an invalid business line number. Example:

      https://github.com/username/projectname/blob/master/file.txt#L10
      
    3. GitHub can NOT make AUTO-link to any file either to (custom commit) nor (master-branch) Because of following business issues:

      • line business meaning, to link to it in the new file
      • length of target highlighted code which can be changed

提交回复
热议问题