How to show git log with commit numbers?
Asked Answered
E

1

9

I found an example on how to delete a commit but it includes git log in the following format

Number  Hash    Commit Message  Author
1   2c6a45b (HEAD) Adding public method to access protected method  Tom
2   ae45fab Updates to database interface   Contractor 1
3   77b9b82 Improving database interface    Contractor 2
4   3c9093c Merged develop branch into master   Tom
5   b3d92c5 Adding new Event CMS Module Paul
6   7feddbb Adding CMS class and files  Tom
7   a809379 Adding project to Git   Tom

When I issue the git log command I'm getting log in another format and without the numbers (which are required by the task).

How to get git log with numbers?

Exactly answered 1/8, 2018 at 9:13 Comment(1)
Sounds weird. Might be worth posting the output that you do get with git log. Also what version of git and what os you're using might help. Be aware that the hash is quite long (like 327bebf545a6024c4e67ecd034cdc1f64a02ce15) but in many situations you only need the first 8 characters ( 327bebf5 )Mindy
H
16

You could combine the nl command with git log --oneline to enumerate output lines. It's far from ideal but if you are just looking for the line numbers:

$ git log --oneline | nl
 1  91236f3 Message
 2  a611069 Message
 3  f2813e7 Message
 4  01b59e4 Message
 5  2343455 Message
Hiatt answered 1/8, 2018 at 9:37 Comment(1)
Or if you want to count from first to current: git log --oneline | tac | nl | tacPointer

© 2022 - 2024 — McMap. All rights reserved.