在 Github 中没有提交就对一行进行注释?

在 github 中,您可以对提交中的行进行注释。有没有一种方法可以在查看分支中的文件时对一行进行注释,而不需要进行特定的提交?

47398 次浏览

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:

You should now be able to comment the file.

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

The only way if you use a different tool for this job. I use Fisheye, or Review-Board for do pre-commit revision code.

Review Board is free, and handle better than Fisheye the pre-commit code.

I wanted to do the same thing, for a code review.

I ended up:

  1. forking the repo
  2. adding my comments in the source code (e.g. // TODO: ...)
  3. making a pull request

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/