Forgot password?
 Create new account
View 97|Reply 2

git怎么编辑旧的commit message

[Copy link]

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2025-3-29 10:24:22 |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

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

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

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

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

手机版Mobile version|Leisure Math Forum

2025-4-20 11:56 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list