git clone changes file modification time

后端 未结 6 891
谎友^
谎友^ 2021-02-02 06:37

When I clone a git repository using \"git clone ...\" command all cloned files in my local repository have the same modification time with date and time when

6条回答
  •  一整个雨季
    2021-02-02 07:08

    This linux one-liner will fix all the files (not folders - just files) - and it will also fix files with spaces in them too:-

    git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="%ai {}" {} | perl -ne 'chomp;next if(/'"'"'/);($d,$f)=(/(^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(?: \+\d\d\d\d|)) (.*)/);print "d=$d f=$f\n"; `touch -d "$d" '"'"'$f'"'"'`;' 
    

提交回复
热议问题