Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show git log with commit numbers?

Tags:

git

git-log

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?

like image 959
Dims Avatar asked Aug 01 '18 09:08

Dims


1 Answers

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
like image 81
Karol Dowbecki Avatar answered Sep 30 '22 14:09

Karol Dowbecki