在 Git 中修改 GitLab 上已经提交的说明
1、现在已将提交推送到 GitLab.com,则必须强制推送含有修正消息的提交。由于提交说明不符合:约定式提交,其网址:https://www.conventionalcommits.org/zh-hans/v1.0.0/
2、参考:https://docs.github.com/cn/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message 。
3、使用 git commit –amend 命令修改提交消息。键入 git commit –amend,然后按 Enter 键。请输入您的更改的提交消息。行首
带有 ‘#’ 的 # 将被忽略。
4、在文本编辑器中编辑提交消息,然后保存该提交。如图1
5、使用 push –force-with-lease 命令强制推送经修改的旧提交。如图2
PS E:\wwwroot\object> git push --force-with-lease origin example-branch Enumerating objects: 19, done. Counting objects: 100% (19/19), done. Delta compression using up to 4 threads Compressing objects: 100% (10/10), done. Writing objects: 100% (10/10), 1.59 KiB | 108.00 KiB/s, done. Total 10 (delta 8), reused 0 (delta 0), pack-reused 0 remote: remote: View merge request for example-branch: remote: https://xxx/themes/object/-/merge_requests/487 remote: To https://xxx/themes/object.git + efb465f5...61478100 example-branch -> example-branch (forced update) PS E:\wwwroot\object>
6、查看 GitLab 上的提交说明,已经增加:feat: 前缀。如图3
近期评论