Git relative revision numbers

前端 未结 4 1657
余生分开走
余生分开走 2020-12-08 08:00

Is it possible (somehow) to have in Git (local) relative revision (commit) numbers, like in Mercurial 0, 1, 2, 3, ... instead of short hashes?

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 08:13

    I just made something doing exactly this: dash-r. It's still rough, but you might find it useful.

    Basically, it's a shim that can produce a modified version of the basic git log with commit lines like so:

    commit 4  id: a4d0892d38f4d72902e35a5b1ca11e602fffcef6
    

    and then reference these numbers by surrounding the -r invocation with backticks:

    git diff `-r 2`
    

    (Assuming you install it in your path with the name "-r". I do that since it looks like a regular option if I ignore the backticks.)

    It can even handle ranges and negative numbers:

    git diff `-r 2..-2`
    

    Git's lack of revision numbers has been a major hurdle for me in warming to Git. Seeing SHA hashes in git log breaks my flow. So I hope it will help both of us.

提交回复
热议问题