Use future date while making git commits

前端 未结 3 1886
小蘑菇
小蘑菇 2020-12-24 09:00

Is there any easy way to postpone GitHub commits?

It would be also nice if these commits will go one after another in 1 hour.
Let\'s say if I have 5 commits, the

3条回答
  •  無奈伤痛
    2020-12-24 09:53

    You can use commit --date argument:

    git commit -m "message" --date "Tue Apr 28 23:00:00 2015 +0300"
    

    UPD: there is also pretty cool script for shifting old commits date (you need Perl to run it): https://raw.githubusercontent.com/gitbits/git-shift/master/git-shift

    perl git-shift +5h 2e6fd0a9dc98403c4fca638e411b3451cbc66a89
    

    UPD2: You can create custom alias in order to shift all new commits automatically. In order to do that, put the following line into your ~/.bashrc file

    alias future-commit='git commit --date "$(date -v +4H)"'
    

    or

    alias future-commit='git commit --date "$(date -d +4hours)"'
    

    reload terminal and now you will be able to commit with +4 hours shift:

    future-commit -m "future commit"
    

提交回复
热议问题