Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 626
mlepage Avatar asked Oct 02 '12 18:10

mlepage


People also ask

How do I comment on a line of code on GitHub?

On the pull request, click Files changed. Hover over the line of code where you'd like to add a comment, and click the blue comment icon. To add a comment on multiple lines, click and drag to select the range of lines, then click the blue comment icon. When you're done, click Add single comment.

How do I comment on a GitHub review?

To add review comments, click the + icon next to the line number. Type your review comment and then click Start Review. When you are finished adding review comments, from the Side Bar you can choose to either submit the comments, approve the changes, or request changes.

How do I link to a line in GitHub?

You can link to a specific line in the Markdown file the same way you can in code. Append #L with the line number or numbers at the end of the url. For example, github.com/<organization>/<repository>/blob/<branch_name>/README.md?


3 Answers

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

like image 62
Farid Movsumov Avatar answered Oct 13 '22 06:10

Farid Movsumov


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.

like image 38
Sebi Avatar answered Oct 13 '22 06:10

Sebi


This blog post provides a simple way to use github's built-in commenting features for this: http://astrofrog.github.io/blog/2013/04/10/how-to-conduct-a-full-code-review-on-github/

like image 22
user553965 Avatar answered Oct 13 '22 04:10

user553965