git log of a single revision

后端 未结 4 1442
醉话见心
醉话见心 2020-12-07 12:08

I have a commit c. I want to get the changeset of that exact commit c + metainformation and no other one. Is there a simpler way than git log -p c^..c to do tha

4条回答
  •  悲哀的现实
    2020-12-07 12:23

    Michal Trybus' answer is the best for simplicity. But if you don't want the diff in your output you can always do something like:

    git log -1 -U c
    

    That will give you the commit log, and then you'll have full control over all the git logging options for your automation purposes. In your instance you said you wanted the change-set. The most human-readable way to accomplish that would be:

    git log --name-status --diff-filter="[A|C|D|M|R|T]" -1 -U c
    

    Or, if you're using a git version greater than 1.8.X it would be:

    git log --name-status --diff-filter="ACDMRT" -1 -U c
    

    This will give you results similar to:

    commit {c}
    Author: zedoo 
    Date: Thu Aug 2 {time-stamp}
    
       {short description}
    D    zedoo/foo.py
    A    zedoo/bar.py
    

    Of course you can filter out whichever events you see fit, and format the return as you wish via the traditional git-log commands which are well documented here.

提交回复
热议问题