change the commit time of a bunch of commits at once

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

change the commit time of a bunch of commits at once

Post by bernd »

This might be interesting for others too ... I really like clean commit history. Thus I like to have no mixed commit dates, and I do not like to have commit dates far away from now in the past. Thus sometimes I set them before going for a merge:

Code: Select all

git filter-branch -f --env-filter \
    'export GIT_AUTHOR_DATE="$now"
     export GIT_COMMITTER_DATE="$now"
     sleep 2s' \
     --tag-name-filter cat -- commitHashFromCommitOneBeforeStartToSet..HEAD

#

example:

Code: Select all

$ git filter-branch -f --env-filter \
>     'export GIT_AUTHOR_DATE="$now"
>      export GIT_COMMITTER_DATE="$now"
>      sleep 2s' \
>      --tag-name-filter cat -- 50f91840d6..HEAD
Rewrite da744827cecce52900c449f345df4d5df2d38a10 (12/12) (22 seconds passed, remaining 0 predicted)    
Ref 'refs/heads/femconcrete' was rewritten
$ 

result:
Screenshot_20190528_234703.png
Screenshot_20190528_234703.png (131.96 KiB) Viewed 597 times


Ahh do not forge git filter-branch can mess up your whole git reopository. Just in case ... you have been warned :mrgreen:
Post Reply