首页 > 其他分享 >git修改已提交的注释

git修改已提交的注释

时间:2022-08-15 10:45:46浏览次数:50  
标签:git 提交 -- rebase 注释 master branch

许久之前的一次提交,如果突然调查历史记录的时候发现日志写的不尽如意,想要重新编写一下,git是可以做到的,但是不太建议

步骤

  • git rebase -i xxx这个是你要修改的提交的前一个提交哈希值,因为git rebase会切换到你指定的哈希值的后一次提交,如果你指定你想提交的哈希值,那么就会在编辑提交日志中看不到你指定的内容

  • 把你要修改日志的那次提交前面的pick改成e,也就是edit,保存退出

  • 运行git commit --amend修改日志,保存退出

  • 运行git rebase --continue

  • 如果提示如下

$ git rebase --continue
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git rebase --skip'
interactive rebase in progress; onto 421b315
Last commands done (26 commands done):
   pick 5a610c9 On branch master  Your branch is up to date with 'origin/master'.
   pick c90f882 add coding utf8  On branch master  Your branch is up to date with 'origin/master'.
  (see more in file .git/rebase-merge/done)
Next commands to do (15 remaining commands):
   pick 76a12e4 On branch master  Your branch is up to date with 'origin/master'.
   pick 4d116fd 增加一个末包时间,方便统计查看  On branch dev  Changes to be committed:         modified:   web/html/i18n/en.json       modified:   web/html/i18n/zh_CN.json     modified:   web/html/js/app.js  modified:   web/html/js/linkage.js
  (use "git rebase --edit-todo" to view and edit)
You are currently rebasing branch 'dev' on '421b315'.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean
Could not apply c90f882... add coding utf8  On branch master  Your branch is up to date with 'origin/master'.

就运行git rebase --skip,直到出现

$ git rebase --skip
Successfully rebased and updated refs/heads/dev.

这样就表示修改完成

注意:使用git rebase后会修改git的提交树,如果和别人一起合作开发,可能会导致大量冲突,如果是自己单独一个分支开发,可能会导致提交顺序或者提交分支之间关系发生变化,如果不是特别需要,不建议修改以前的提交日志,每次提交编写日志的时候,尽可能的详细规范。

标签:git,提交,--,rebase,注释,master,branch
From: https://www.cnblogs.com/studywithallofyou/p/16587387.html

相关文章

  • git学习(02)git下载安装与配置
    下载打开 Git官网,点击 DownloadforWindows由于国内网络限制,一般下载会很缓慢。国内可以使用 淘宝镜像下载 或者 华为镜像下载其他的国外资源下载缓慢都可......
  • git学习(01) git的概念及相关介绍
    git的定义Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。Git是LinusTorvalds为了帮助管理Linux内核开发而开发的一个开放源码的版本......
  • 听,引擎的声音「GitHub 热点速览 v.22.33」
    这期的热点速览异常Cool,因为有呜呜声内燃机引擎加成的engine-simengine-sim坐镇,听到如此曼妙的引擎声,相比你的人生也在高速上升吧。还有,自己搭建个服务就能在本地用上......
  • git tag All In One
    gittagAllInOne#查看所有tags$gittaggitdeletetag#删除tagv1.1.1✅$gittag-dv1.1.1$gitpushorigin:refs/tags/v1.1.1#删除tagv1.1.2......
  • 05-集群提交:spark-submit脚本
    结构:命令+选项+文件+参数基础选项:优先级:代码中配置【程序特有】>参数选项【运行模式、程序名称、资源选项】>配置文件【公共配置】--master:用于指定程序的......
  • oracle常用查字段注释
    selectB.column_id,B.owner,B.table_name,b.column_name,b.comments,casewhenB.data_typeIN('VARCHAR2','CHAR','NVARCHAR2','NCHAR')thenB.data_typ......
  • Windows下 git: Failed to connect to 127.0.0.1 port 1080: Connection refused报错
    问题git无法拉取代码,报错:Failedtoconnectto127.0.0.1port1081:Connectionrefused解决找到系统账户下.gitconfig文件,删除里面配置的代理,保存即可解决此问题本......
  • git 常见命令整理
    一、git基本操作命令释意常用gitaddfilename添加filename到暂存区是gitadd.添加当前所有修改文件到暂存区是gitcommit-m'备注'对已经add的文......
  • centos7使用 Docker Engine部署gitlab
    1.安装docker-ce卸载旧版本:yumremovedockerdocker-commondocker-selinuxdocker-engine一、虚拟机联网,安装yum工具执行以下命令yuminstall-yyum-utils\dev......
  • 极狐gitlab runner 使用 cache 实例
    极狐gitlabrunner使用cache实例参考官方文档:DockerMachineExecutorautoscaleconfiguration|GitLabCachinginGitLabCI/CD|GitLabSpeedupjobexecutio......