Git推送时间修改

这里写自定义目录标题

    • [⏰ Git 提交时间戳详解](#⏰ Git 提交时间戳详解)
      • [1. 远程识别的时间](#1. 远程识别的时间)
      • [2. 修改已提交的时间戳](#2. 修改已提交的时间戳)
    • [📅 时间格式参考](#📅 时间格式参考)

⏰ Git 提交时间戳详解

1. 远程识别的时间

Git 提交包含两个时间戳:

  • Author Date(作者日期):代码实际编写的日期(你的本地 3月1日)
  • Commit Date (提交日期):代码被提交到仓库的日期(你的 3月6日)
    远程服务器看到的是:
  • Author Date = 2026-03-01(你本地的 commit 时间)
  • Commit Date = 2026-03-06 (你执行 git push的时间)
    在 GitLab 界面上,通常显示的是 Author Date(3月1日),但点击提交详情可以看到两个时间。

2. 修改已提交的时间戳

bash 复制代码
# 1. 重置提交,不改变代码内容
git commit --amend --no-edit --date="2026-03-06T14:30:00"

# 2. 强制推送到远程
git push --force-with-lease

参数说明:

  • --amend:修改上一次提交
  • --no-edit:不修改提交信息
  • --date:设置新的作者日期(格式:YYYY-MM-DD HH:MM:SS 或 ISO8601)

📅 时间格式参考

bash 复制代码
# ISO 8601 格式(推荐)
--date="2026-03-06T14:30:00+08:00"

# 相对时间
--date="2 days ago"
--date="yesterday 14:30"

# RFC 2822 格式
--date="Fri, 6 Mar 2026 14:30:00 +0800"

# Unix 时间戳
--date="@1770000000"
相关推荐
淘矿人1 天前
从0到1:用Claude启动你的第一个项目
开发语言·人工智能·git·python·github·php·pygame
lpfasd1231 天前
Git/Gitee/GitHub 3 个安全凭证详解
git·gitee·github
李日灐1 天前
< 7 > Linux 开发工具:git 版本控制器 和 cgdb/gdb 调试器
linux·运维·服务器·开发语言·git·调试器·gdb/cgdb
Gust of wind1 天前
idea结合git和Gitee的初步使用
git·gitee·intellij-idea
夜七少eleanor1 天前
【Git】2026全图文详解安装教程
git
海边的Kurisu1 天前
从零开始的Git生活 | 刚实习同学的噩梦 And 参与开源不可缺的一环
git·生活
不老刘1 天前
Git Cherry-Pick:微前端架构下的“精准医疗”与最佳实践
前端·git
爬楼的猪1 天前
Git Folder Dashboard
git
Uncertainty!!1 天前
claude code中添加skills自动生成git commit信息
git·git commit·claude code
FserSuN1 天前
Git Worktree 使用学习
git·学习