Git常用命令整理

  1. 修改git commit时间
    有时候出于一些原因,需要把最近一次已经commit过的记录的时间改成当前时间,可以用命令:
git commit --amend --date="now"

也可以改为指定时间格式:

git commit --amend --date="Mon Jan 25 10:37:36 2024 +0300"

如果是要修改更早之前的commit记录的时间,则需要搭配使用git rebase。
1)首先rebase指定的父提交节点:

git rebase -i <parent_commit_hash>
  1. 修改提交时间:
GIT_COMMITTER_DATE="Wed Jan 9 22:00 2024 +0530" git commit --amend --no-edit

  1. 完成rebase
git rebase --continue

posted @ 2024-04-23 10:00  freephp  阅读(7)  评论(0编辑  收藏  举报