githubpycharmpermalinks

Github permalink from Pycharm?


I use the Github integration in PyCharm, and often I need to share permalinks to reference code to colleagues in slack messages, Github issues/PRs. To get the permalink, I have to open the repository in a browser, navigate to the file where the code is, and click on the left side pop-up menu option "Copy permalink" (e.g. https://github.com/opencog/opencog/blob/b7104ce702642da3b50511c5c59e015cf1669ac6/CMakeLists.txt#L2). This is a cumbersome process.

Is there a way to obtain such permalink from PyCharm directly?

I checked the Git submenu and there's no such option. I also didn't find much in PyCharm's documentation :(


Solution

  • Not exactly the ideal solution, but something close to it:

    You can highlight the code lines in PyCharm, right click and select "Open in --> GitHub" and choose the fork where you want to see them. This opens the desired file in a browser tab, with the lines of interest already highlighted. You can then click on the left side of the lines to get the permalink.

    This automates the step of navigating in a browser to the exact location in the repository where the file is, which is a decent time saver.