当前位置: 首页 » 综合知识 » it知识 » 正文

git如何修mit时间

发布时间:2023-07-12 以下文章来源于网友投稿,内容仅供参考!

在git中,可以利用“gitmit --amend”命令来修mit时间;该方法既可以修改最近一次提交的日期,也可以修改指定某次提交的日期,其中日期的格式需要是“ISO-8601”格式,语法为“GITMITTER_DATE="时间" gitmit --amend --date="时间"”。

本文操作环境:Windows10系统、Git2.30.0版、Dell G3电脑。

git修mit时间

1.修改最近一次提交的作者日期和提交者日期

如果要修改最近一mit的作者日期和提交者日期,直接使用 gitmit --amend即可

注:日期格式须为ISO-8601格式

GITMITTER_DATE="2022-10-08T09:51:07" git mit --amend --date="2022-10-08T09:51:07"

2.修改某次提交的作者日期和提交者日期

如果要更改某次(可以是最近一次也可以是非最近一次)提交的作者日期和提交者日期,可以使用交互式rebase:

3.修改示例

当前git log提交信息如下

admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master)
$ git log --oneline
2fe64c4 (HEAD -> master) modify Readme.md 3
6b98331 modify Readme.md 2
98ddd80 modify Readme.md 1
fcfc064 add Readme.md

假设此时需要修改 6b98331 modify Readme.md 2这mit的作者日期和提交者日期

修改步骤为:

执行交互式变基命令 git rebase -i 98ddd80

在弹出的vi编辑信息中,将 6b98331提交前的pick修改为e,随后执行 :wq 保存

e  6b98331 modify Readme.md 2      # 此处原为pick,将pick修改为e / edit
pick 2fe64c4 modify Readme.md 3
# Rebase 98ddd80..2fe64c4 onto 98ddd80 (2 mands)
#
# mands:
# p, pick <mit> = use mit
# r, reword <mit> = use mit, but edit the mit message
# e, edit <mit> = use mit, but stop for amending
# s, squash <mit> = use mit, but meld into previous mit
# f, fixup <mit> = like "squash", but discard this mit's log message
# x, exec <mand> = run mand (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <mit> = remove mit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <mit> | -c <mit>] <label> [# <oneline>]
# .       create a merge mit using the original merge mit's
# .       message (or the oneline, if no original merge mit was
# .       specified). Use -c <mit> to reword the mit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT MIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.

执行 GITMITTER_DATE="2022-10-22T15:10:07" gitmit --amend --date="2022-10-22T15:10:07" 将作者日期和提交者日期均修改为2022-10-22T15:10:07。然后可选择在弹出的vi信息编辑窗中可修改提交日志,然后执行 :wq 保存

然后执行 git rebase --continue转到下一个提交,直到保存所有修改。完成后再使用git log查看提交信息即可看到提交信息已被修改

上述示例的完整日志如下:

admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master)
$ git log --oneline
2fe64c4 (HEAD -> master) modify Readme.md 3
6b98331 modify Readme.md 2
98ddd80 modify Readme.md 1
fcfc064 add Readme.md
admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master)
$ git rebase -i 98ddd80
Stopped at 6b98331...  modify Readme.md 2
You can amend the mit now, with
  git mit --amend
Once you are satisfied with your changes, run
  git rebase --continue
admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master|REBASE 1/2)
$ GITMITTER_DATE="2022-10-22T15:10:07" git mit --amend --date="2022-10-22T15:10:07"
[detached HEAD 137f41d] modify Readme.md 2
 Date: Fri Oct 22 15:10:07 2022 +0800
 1 file changed, 16 insertions(+)
admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master|REBASE 1/2)
$ git status
interactive rebase in progress; onto 98ddd80
Last mand done (1 mand done):
   edit 6b98331 modify Readme.md 2
Next mand to do (1 remaining mand):
   pick 2fe64c4 modify Readme.md 3
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a mit while rebasing branch 'master' on '98ddd80'.
  (use "git mit --amend" to amend the current mit)
  (use "git rebase --continue" once you are satisfied with your changes)
nothing to mit, working tree clean
admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master|REBASE 1/2)
$ git rebase --continue
Successfully rebased and updated refs/heads/master.
admin@DESKTOP-PC MINGW64 /e/TestProj/ModifyTimeTest (master)
$ git status
On branch master
nothing to mit, working tree clean
  • • Linux Ecdsa密钥长度选择有何依据

    在Linux

  • • Linux Khook在内核监控中的应用如何

    Linux

  • • Linux Gsoap是否支持异步通信

    GSOAP是

  • • Linux Coremail如何提升用户体验

    提升Linu

  • • Linux Ecdsa算法有哪些局限性

    ECDSA

  • 哎呀音乐钢琴键盘学习《 钢琴主人训练营》 西瓜学琴
    郭蝈 陪练钢琴 30节课时 考级刚需 让孩子每一次练琴都是高质量的
    30天轻松学会五线谱 流行钢琴自学初级教程 牙牙学琴
    流行爵士钢琴实战技巧VIP课 - 继伟 哎呀音乐
    【海上钢琴师】原版 MT1990钢琴谱
    百首经典流行钢琴实战曲集 - 继伟
    雷费尔德电钢琴重锤88键专业考级儿童初学者数码电子钢琴家用
    小练咖 真人钢琴陪练 1v1服务 2999随时退 1课时50分钟 考级刚需
    雅马哈电钢琴88键重锤CLP735智能数码电子钢琴家用专业初学者考级
    【原装进口】Yamaha/雅马哈钢琴 b121 SC2原声静音钢琴
  • 珠海专业调钢琴
  • 天津宝坻区调钢琴
  • 天津静海区钢琴调音
  • 成都简阳市钢琴调律
  • 大连瓦房店市钢琴调音
  • 眉山调钢琴联系方式
  • 惠州大亚湾钢琴调琴师
  • 长治调琴师
  • 厦门湖里区钢琴调音师
  • 上海普陀区钢琴调音师