Git show files that were changed in the last 2 days

前端 未结 5 1710
小蘑菇
小蘑菇 2021-01-30 02:56

How can I have a list with all the files that were changed in the last 2 days? I know about

git log --name-status --since=\"2 days ago\" 

but

5条回答
  •  借酒劲吻你
    2021-01-30 03:33

    git diff --stat @{2.days.ago} # Deprecated!, see below
    

    Short and effective

    Edit

    TLDR: use git diff $(git log -1 --before=@{2.days.ago} --format=%H) --stat

    Long explanation: The original solution was good, but it had a little glitch, it was limited to the reflog, in other words, only shows the local history, because reflog is never pushed to remote. This is the reason why you get the warning: Log for 'master' only goes back to... in repos recently cloned.

    I have configured this alias in my machine:

    alias glasthour='git diff $(git log -1 --before=@{last.hour} --format=%H) --stat' 
    alias glastblock='git diff $(git log -1 --before=@{4.hours.ago} --format=%H) --stat' 
    alias glastday='git diff $(git log -1 --before=@{last.day} --format=%H) --stat' 
    alias glastweek='git diff $(git log -1 --before=@{last.week} --format=%H) --shortstat | uniq' 
    alias glastmonth='git diff $(git log -1 --before=@{last.month} --format=%H) --shortstat | uniq'                                                                                                                
    

    credits: answer below by @adam-dymitruk

提交回复
热议问题