githug 第 45 关, 一开始对 git rebase -i 这个东西有误解, 记录一下正确的用法

  1. ddmobadeMac-mini:git_hug ddmoba$ githug reset 45
  2. ********************************************************************************
  3. * Githug *
  4. ********************************************************************************
  5. resetting level
  6. Name: rename_commit
  7. Level: 45
  8. Difficulty: ***
  9. Correct the typo in the message of your first (non-root) commit.
  10. ddmobadeMac-mini:git_hug ddmoba$

查找有拼写错误的那一条 commit

  1. ddmobadeMac-mini:git_hug ddmoba$ git log
  2. commit d30bc005638c278714faaa73f0fdc16052561750 (HEAD -> master)
  3. Author: hangj <hangj@protonmail.com>
  4. Date: Fri Jun 29 11:35:05 2018 +0800
  5. Second commit
  6. commit 4f1341ac9134225719e5d704e420160657e8c38e
  7. Author: hangj <hangj@protonmail.com>
  8. Date: Fri Jun 29 11:35:05 2018 +0800
  9. First coommit
  10. commit a632e3dfa31a06bcec9395c0690d43a3f2f09706
  11. Author: hangj <hangj@protonmail.com>
  12. Date: Fri Jun 29 11:35:05 2018 +0800
  13. Initial commit
  14. ddmobadeMac-mini:git_hug ddmoba$

First coommit // commit 写错了

git rebase -i parent_of_flawed_commit

  1. ddmobadeMac-mini:git_hug ddmoba$ git rebase -i a632e3dfa31a06bcec9395c0690d43a3f2f09706

然后跳到

  1. pick 4f1341a First coommit
  2. pick d30bc00 Second commit
  3. # Rebase a632e3d..d30bc00 onto a632e3d (2 commands)
  4. #
  5. # Commands:
  6. # p, pick = use commit
  7. # r, reword = use commit, but edit the commit message
  8. # e, edit = use commit, but stop for amending
  9. # s, squash = use commit, but meld into previous commit
  10. # f, fixup = like "squash", but discard this commit's log message
  11. # x, exec = run command (the rest of the line) using shell
  12. # d, drop = remove commit
  13. #
  14. # These lines can be re-ordered; they are executed from top to bottom.
  15. #
  16. # If you remove a line here THAT COMMIT WILL BE LOST.
  17. #
  18. # However, if you remove everything, the rebase will be aborted.
  19. #
  20. # Note that empty commits are commented out
  21. ~
  22. ~
  23. ~
  24. ~
  25. ~
  26. ~
  27. ~
  28. ~
  29. ~
  30. ~
  31. ~
  32. ~
  33. "~/git_hug/.git/rebase-merge/git-rebase-todo" 21L, 693C

编辑它,

  1. r 4f1341a First coommit
  2. pick d30bc00 Second commit
  3. # Rebase a632e3d..d30bc00 onto a632e3d (2 commands)
  4. #
  5. # Commands:
  6. # p, pick = use commit
  7. # r, reword = use commit, but edit the commit message
  8. # e, edit = use commit, but stop for amending
  9. # s, squash = use commit, but meld into previous commit
  10. # f, fixup = like "squash", but discard this commit's log message
  11. # x, exec = run command (the rest of the line) using shell
  12. # d, drop = remove commit
  13. #
  14. # These lines can be re-ordered; they are executed from top to bottom.
  15. #
  16. # If you remove a line here THAT COMMIT WILL BE LOST.
  17. #
  18. # However, if you remove everything, the rebase will be aborted.
  19. #
  20. # Note that empty commits are commented out
  21. ~
  22. ~
  23. ~
  24. ~
  25. ~
  26. ~
  27. ~
  28. ~
  29. ~
  30. ~
  31. ~
  32. ~
  33. -- INSERT --

然后 :x 保存, 会跳到

  1. First coommit
  2. # Please enter the commit message for your changes. Lines starting
  3. # with '#' will be ignored, and an empty message aborts the commit.
  4. #
  5. # Date: Fri Jun 29 11:35:05 2018 +0800
  6. #
  7. # interactive rebase in progress; onto a632e3d
  8. # Last command done (1 command done):
  9. # r 4f1341a First commit
  10. # Next command to do (1 remaining command):
  11. # pick d30bc00 Second commit
  12. # You are currently editing a commit while rebasing branch 'master' on 'a632e3d'.
  13. #
  14. # Changes to be committed:
  15. # new file: file1
  16. #
  17. ~
  18. ~
  19. ~
  20. ~
  21. ~
  22. ~
  23. ~
  24. ~
  25. ~
  26. ~
  27. ~
  28. ~
  29. ~
  30. ~
  31. ~
  32. ~
  33. "~/git_hug/.git/COMMIT_EDITMSG" 17L, 520C

编辑它, 把 coommit 改成 commit

  1. First commit
  2. # Please enter the commit message for your changes. Lines starting
  3. # with '#' will be ignored, and an empty message aborts the commit.
  4. #
  5. # Date: Fri Jun 29 11:35:05 2018 +0800
  6. #
  7. # interactive rebase in progress; onto a632e3d
  8. # Last command done (1 command done):
  9. # r 4f1341a First commit
  10. # Next command to do (1 remaining command):
  11. # pick d30bc00 Second commit
  12. # You are currently editing a commit while rebasing branch 'master' on 'a632e3d'.
  13. #
  14. # Changes to be committed:
  15. # new file: file1
  16. #
  17. ~
  18. ~
  19. ~
  20. ~
  21. ~
  22. ~
  23. ~
  24. ~
  25. ~
  26. ~
  27. ~
  28. ~
  29. ~
  30. ~
  31. ~
  32. ~
  33. -- INSERT --

然后 :x 保存, 跳到

  1. ddmobadeMac-mini:git_hug ddmoba$ git rebase -i a632e3dfa31a06bcec9395c0690d43a3f2f09706
  2. [detached HEAD ea3efe3] First commit
  3. Date: Fri Jun 29 11:35:05 2018 +0800
  4. 1 file changed, 0 insertions(+), 0 deletions(-)
  5. create mode 100644 file1
  6. Successfully rebased and updated refs/heads/master.

然后 git log 查看一下是否修改成功

  1. ddmobadeMac-mini:git_hug ddmoba$ git log
  2. commit 1f929783b1acb295aaf7b9dbe500629a1054484f (HEAD -> master)
  3. Author: hangj <hangj@protonmail.com>
  4. Date: Fri Jun 29 11:35:05 2018 +0800
  5. Second commit
  6. commit ea3efe310a6a03a232171bf664401f62a5dc024e
  7. Author: hangj <hangj@protonmail.com>
  8. Date: Fri Jun 29 11:35:05 2018 +0800
  9. First commit
  10. commit a632e3dfa31a06bcec9395c0690d43a3f2f09706
  11. Author: hangj <hangj@protonmail.com>
  12. Date: Fri Jun 29 11:35:05 2018 +0800
  13. Initial commit
  14. ddmobadeMac-mini:git_hug ddmoba$

done !!

githug rename_commit 修改已经commit但还没push的一条message的更多相关文章

  1. git 检查是否有commit到本地但还没push的代码

    使用 git status 命令可以得到以下结果 $ git status On branch dev_getTicketCnt Your branch is ahead of 'origin/mas ...

  2. Git 还没push 前可以做的事(转)

    Git 版本控制系統(3) 還沒 push 前可以做的事 转载:http://ihower.tw/blog/archives/2622   這一集要講的是:還沒 push 前可以做的壞事,也就是 re ...

  3. git删除已经提交的包含敏感信息的文件(还没提交到远程仓库)

    写好的代码已经提交了(但还没push到github),发现某个文件里包含密码.如果push的话,密码可就被公开了.如果在代码里改掉密码,再commit一次,也不行,历史提交记录还是会上传到github ...

  4. 谁还没遇上过NoClassDefFoundError咋地——浅谈字节码生成与热部署

    谁还没遇上过NoClassDefFoundError咋地--浅谈字节码生成与热部署 前言 在Java程序员的世界里,NoClassDefFoundError是一类相当令人厌恶的错误,因为这类错误通常非 ...

  5. C-Lodop提示“网页还没下载完毕,请稍等一下再操作.”

    该提示在Lodop旧版本中是: 提示"WebSocket没准备好,点确定继续",提示“C-Lodop没准备好”,新版本修改了该提示的描述“网页还没下载完毕,请稍等一下再操作.”,让 ...

  6. .Net Actor 服务端开发框架,Newbe.Claptrap 项目周报 1 - 还没轮影,先用轮跑

    Newbe.Claptrap 项目周报 1,第一周代码写了一点.但主要还是考虑理论可行性. 第一次接触本框架的读者,可以先点击此处阅读本框架相关的基础理论和工作原理. 周报是啥? 成功的开源作品,离不 ...

  7. 不会吧,你连Java 多线程线程安全都还没搞明白,难怪你面试总不过

    什么是线程安全? 当一个线程在同一时刻共享同一个全局变量或静态变量时,可能会受到其他线程的干扰,导致数据有问题,这种现象就叫线程安全问题. 为什么有线程安全问题? 当多个线程同时共享,同一个全局变量或 ...

  8. gRPC趁现在还没大火,抢先了解一下

    前言 系统分布式已经成为程序员的家常,将大型单体划分为相对简单的小模块,分散系统能力,提升系统扩展性.功能模块复用性等:各功能模块之间肯定会有很多数据共享和交互的应用场景,那就避免不了各模块之间的通信 ...

  9. 升级过log4j,却还没搞懂log4j漏洞的本质?

    摘要:log4j远程代码漏洞问题被大范围曝光后已经有一段时间了,今天完整讲清JNDI和RMI以及该漏洞的深层原因. 本文分享自华为云社区<升级过log4j,却还没搞懂log4j漏洞的本质?为你完 ...

随机推荐

  1. ubuntu彻底卸载软件

    找到此软件名称,然后sudo apt-get purge ......(点点为为程序名称),purge参数为彻底删除文件,然后sudo apt-get autoremove,sudo apt-get ...

  2. Java中的包装数据类型

    基本类型 包装器类型 boolean Boolean char Character int Integer byte Byte short Short long Long float Float do ...

  3. chart.js应用中遇到的问题

    问题一:chart.js的版本问题:打开官网https://github.com/chartjs/Chart.js/releases/tag/v2.7.3,点击Tags,选择最新版本,我这里选用的是V ...

  4. HttpRunnerManager安装部署

    uname -a cat /etc/redhat-release 1.安装docker.mysql.rabbitmq sudo yum update curl -fsSL https://get.do ...

  5. 安装php调试工具 Xdebug的步骤 火狐 phpstorm联调

    一 安装服务器端 1 选择你的版本 <?php phpinfo(); ?> 比如我的: 关键是这三项:PHP Version 7.3.0Architecture x86 (x86是32位系 ...

  6. 【测试工具】Macaca 自动遍历器 NoSmoke

    Macaca 提供的基础能力上研发出了一套多端深度遍历爬虫工具. 希望可以最大化减少UI 测试脚本的编写涵盖以下功能点: 支持iOS, Android,PC-Web 三个平台的自动化测试 同时可以通过 ...

  7. MYSQL、SQL在LIKE里传的参数没有赋进去的原因

    SQL语句 = string.Format(" where name like '%@key%' "); para.Add(new MySqlParameter("@ke ...

  8. 微软Office Online服务安装部署(三)

    现在开始配置两台服务器,两台服务器的IP: Server: 10.1.3.89 Client:  10.1.3.92 1.在Client中,.打开网络属性,找到ipv4的配置,将dns 改成域控制器的 ...

  9. C#,如何程序使用正则表达式如何使用匹配的位置的结果修改匹配到的值

    程序代码使用正则表达式如何修改匹配到的值: 代码一: using System; using System.Text.RegularExpressions; public class Example ...

  10. MySQL开发——【联合查询、多表连接、子查询】

    联合查询 所谓的联合查询就是将满足条件的结果进行拼接在同一张表中. 基本语法: select */字段 from 数据表1 union [all | distinct] select */字段 fro ...