Lerner Zhang
Lerner Zhang

Reputation: 7130

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.

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? I only know a little about the plumbing commands of Git. Maybe in repository/branch/file/line form?

Upvotes: 2

Views: 125

Answers (1)

fpietka
fpietka

Reputation: 1043

You could use git show and output it to vim along with a specific line number like the following:

git show branch_name:your_file | vim - +45

or use a specific hash:

git show b4524bcd:your_file | vim - +45

Upvotes: 2

Related Questions