Comment on a line in Github without a commit?

In github, you can comment on lines in a commit. Is there a way to comment on a line, while viewing a file in a branch, without having a particular commit?


Unfortunately it is not possible to comment on a line in Github without a commit.

But you can create links to lines in your file (click on line and copy link on browser bar). For example you can use this links in your issues to discuss about code line:

https://github.com/sebastianbergmann/phpunit/blob/master/src/Runner/StandardTestSuiteLoader.php#L72

Update

You can also hold shift to obtain a link to a block of lines


You should have at least one commit: your initial import ;-) So if you never touched the file afterwards, you can still browse your master branch (or wherever you did the initial import to).

To get to a commit of file, do as follows:

  • open homepage of your repo, e.g. here Ruby on Rails
  • browse to the file you like to comment, e.g. Rails' .gitignore file
  • there's a button called history, click it to see latest commits of this file
  • look for a commit and click the link with the revision ID

You should now be able to comment the file.