• git修改已提交的注释


    许久之前的一次提交,如果突然调查历史记录的时候发现日志写的不尽如意,想要重新编写一下,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的提交树,如果和别人一起合作开发,可能会导致大量冲突,如果是自己单独一个分支开发,可能会导致提交顺序或者提交分支之间关系发生变化,如果不是特别需要,不建议修改以前的提交日志,每次提交编写日志的时候,尽可能的详细规范。

  • 相关阅读:
    2020软件工程作业04
    2020软件工程作业03
    2020软件工程作业02
    2020软件工程作业01
    2020软件工程作业02
    2020软件工程作业01
    WEB学习路线2019完整版(附视频教程+网盘下载地址)
    (2018干货系列七)最新大数据学习路线整合
    (2018干货系列六)最新云计算学习路线整合
    (2018干货系列五)最新UI设计学习路线整合
  • 原文地址:https://www.cnblogs.com/studywithallofyou/p/16587387.html
Copyright © 2020-2023  润新知