Automatically create a link to some file in the current repo

Hi !
I am creating an assignment where the students should modify some python notebook

I would like to create a badge “open in colab” automatically in their README.md file, that would reference their own assignment repository

In practice, this means being able to write the following in the README.md

https://colab.research.google.com/github/ACCOUNT_AND_REPO/blob/master/somenotebook.ipynb

As far as I know, it cannot be done programmatically upon repository creation. However, I’d be very interested in hearing about possible solutions, maybe through GitHub Actions?

i follow this phython give git hub link we can pull request to your programes i like it

https://help.github.com/en/github/managing-files-in-a-repository/getting-permanent-links-to-files

File views show the latest version on a branch

When viewing a file on GitHub, you usually see the version at the current head of a branch. For example:

refers to GitHub’s hubot repository, and shows the master branch’s current version of the README.md file.

The version of a file at the head of branch can change as new commits are made, so if you were to copy the normal URL, the file contents might not be the same when someone looks at it later.

Press y to permalink to a file in a specific commit

For a permanent link to the specific version of a file that you see, instead of using a branch name in the URL (i.e. the master part in the example above), put a commit id. This will permanently link to the exact version of the file in that commit. For example:

replaces master with a specific commit id and the file content will not change.

Looking up the commit SHA by hand is inconvenient, however, so as a shortcut you can type y to automatically update the URL to the permalink version. Then you can copy the URL knowing that anyone you share it with will see exactly what you saw.

Tip : You can put any identifier that can be resolved to a commit in the URL, including branch names, specific commit SHAs, or tags!

Referencing files from within a repository using relative links is quite easy in GitHub. However, this is not what the OP was looking for, which instead boils down to a link hidden behind a badge resulting from the combination of a URL like Colab or Gitpod plus the GitHub account and repo of the user.

© 2017 GitHub, Inc.
with by
GitHub Education