1

I need to get

  1. the changed files names
  2. for every added line, its line number

E.g. given this commit, I want to get compat/unsetenv.c and 5,6,7.

I was trying to use

git show <commit-id> 

and do some dirty string matching on it. I can get away with a

| grep +++ 

for the file name, but I found no way of making git show the line number next to the + sign, as in the GitHub web interface.

Is there any other way to find the (added) line numbers?

4
  • 1
    git blame shows line numbers. Will that work? Commented Jul 27, 2013 at 16:56
  • Relevant? stackoverflow.com/questions/8259851/… Commented Jul 27, 2013 at 17:04
  • 1
    Thank you @CarlNorum for putting me on the right track: git blame --porcelain <filename> | grep <id> | awk '{print $2}' does the job. It still feels like a messy way of doing it, but as long as it works... Commented Jul 27, 2013 at 17:46
  • you shoul try: git diff --stat Commented Jul 28, 2013 at 8:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.