Forgot password?
 Register account
View 236|Reply 2

git怎么编辑旧的commit message

[Copy link]

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

hbghlyj Posted 2025-3-29 10:24 |Read mode
先执行
  1. git replace --edit 7f3385a
Copy the Code
出来一个编辑器,编辑完成后保存退出,再push发现remote上的commit message竟没变,需要执行
  1. git filter-branch -- --all
Copy the Code
看不懂git文档,也不知道filter-branch是啥,好像把所有的历史都重写了一遍,花了挺长时间的,最后git push -f 就看到已经改好了。

Related threads

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2025-3-29 10:23
如果想保存文件的各版本,且需要修改编辑历史,还是用其他工具比较好。Git的编辑历史不太好编辑,尤其是在merge conflict后,若要修改merge前的历史则需要重新merge,太麻烦了

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2025-3-29 10:27
hbghlyj 发表于 2025-3-29 02:23
Git的编辑历史不太好编辑
但Git的最后一次编辑历史很容易编辑,用commit --amend就行了。

Mobile version|Discuz Math Forum

2025-6-4 17:19 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit