Search code examples
gitpycharmjetbrains-ide

How to find the URL of the code line from PyCharm


As a developer working in a team, I do the coding in my IDE (PyCharm) but once I want to discuss a line of the code with the team, I go to GitHub/GitLab/Bitbucket/etc and find the code I am working on, and click on the left side that the line number of the code is showing and it generate the URL of the code for me. I send the URL to a team member. A sample URL from an open source project is https://github.com/django/django/blob/main/django/forms/forms.py#L58

The problem is this is a little time consuming, each time I have to find the URL, especially when the project has many levels of directories.

I am wondering, is it there a shortcut/hotkey in PyCharm that I can use to get the URL of the line of code on the remote repository or at least the file I am working on?


Solution

  • is it there a shortcut/hotkey in PyCharm that I can use to get the URL of the line of code on the remote repository or at least the file I am working on?

    Please check Main Menu | Edit | Copy Path/Reference...

    enter image description here
    (the pic is from JetBrains PyCharm help page)

    If invoked when a focus is in the Editor on some line (no repo configured in this test project hence no GitHub option here):
    enter image description here


    If the above does not do what you need, please check GitLink plugin then: https://plugins.jetbrains.com/plugin/8183-gitlink

    A JetBrains plugin providing shortcuts to open or copy a file, directory or commit in GitHub, Bitbucket, GitLab, Gitee Gitea, Gogs, Azure or Gerrit. Custom hosts can also be configured using the URL template syntax.