简体   繁体   English

如何链接到git上的特定行号?

[英]How to link to specific line number on git?

I searched everywhere, only to find a very similar question but about GitHub rather than Git on Stack Overflow.我到处搜索,只找到一个非常相似的问题,但关于 GitHub 而不是 Stack Overflow 上的 Git。

I need a link locally referring to a line in a branch in a file and in a repository.我需要一个本地链接,引用文件和存储库中分支中的一行。 I know I can do it by using a global mark, for instance in Vim, but can I skin a cat in a Git way?我知道我可以通过使用全局标记来做到这一点,例如在 Vim 中,但我可以用 Git 方式给猫剥皮吗? I only know a little about the plumbing commands of Git.我对 Git 的管道命令只知道一点。 Maybe in repository/branch/file/line form?也许以repository/branch/file/line形式?

You could use git show and output it to vim along with a specific line number like the following:您可以使用git show并将其与特定行号一起输出到 vim,如下所示:

git show branch_name:your_file | vim - +45

or use a specific hash:或使用特定的哈希:

git show b4524bcd:your_file | vim - +45

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM