IDEA
IDEA中支持查看每行代码的commit信息,这是靠git blame命令来完成的。


鼠标悬置在上面,可以看到更多信息。

VScode
vscode中有相应插件完成类似的工作。
找到一个Git Blame插件,就是专门用来完成这项工作的。

安装完成后,下面的状态栏就会显示光标所在行的代码的git blame信息。

点击它,弹窗显示commit信息。

点击Terminal,则构造git show命令来显示该commit的完整提交日志。

点击Online,则自动构造一个url去访问。

手动构造commit对应url的方法
如果你的代码托管在 GitHub 上,你可以通过以下格式构造 commit 的链接:
https://github.com/\<username>/<repository>/commit/<commit_id>
其中,<username> 是仓库所有者的用户名,<repository> 是仓库的名字,<commit_id> 是 commit 的 ID。
例如,如果你的代码托管在 GitHub 上,用户名是 apache,仓库名是 bookkeeper,commit id 是 bd50cacd2b759d53b06a2356c5a9369b6100d635,那么 commit 的链接就是:
https://github.com/apache/bookkeeper/commit/bd50cacd2b759d53b06a2356c5a9369b6100d635
你可以将这个链接复制到浏览器中打开,查看该 commit 的详细信息。