首页 技术 正文
技术 2022年11月11日
0 收藏 391 点赞 3,848 浏览 3877 个字

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

ddmobadeMac-mini:git_hug ddmoba$ githug reset 45
********************************************************************************
* Githug *
********************************************************************************
resetting levelName: rename_commit
Level: 45
Difficulty: ***Correct the typo in the message of your first (non-root) commit.ddmobadeMac-mini:git_hug ddmoba$

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

ddmobadeMac-mini:git_hug ddmoba$ git log
commit d30bc005638c278714faaa73f0fdc16052561750 (HEAD -> master)
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 Second commitcommit 4f1341ac9134225719e5d704e420160657e8c38e
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 First coommitcommit a632e3dfa31a06bcec9395c0690d43a3f2f09706
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 Initial commit
ddmobadeMac-mini:git_hug ddmoba$

First coommit // commit 写错了

git rebase -i parent_of_flawed_commit

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

然后跳到

pick 4f1341a First coommit
pick d30bc00 Second commit# Rebase a632e3d..d30bc00 onto a632e3d (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
~
~
~
~
~
~
~
~
~
~
~
~
"~/git_hug/.git/rebase-merge/git-rebase-todo" 21L, 693C

编辑它,

r 4f1341a First coommit
pick d30bc00 Second commit# Rebase a632e3d..d30bc00 onto a632e3d (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
~
~
~
~
~
~
~
~
~
~
~
~
-- INSERT --

然后 😡 保存, 会跳到

First coommit# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Fri Jun 29 11:35:05 2018 +0800
#
# interactive rebase in progress; onto a632e3d
# Last command done (1 command done):
# r 4f1341a First commit
# Next command to do (1 remaining command):
# pick d30bc00 Second commit
# You are currently editing a commit while rebasing branch 'master' on 'a632e3d'.
#
# Changes to be committed:
# new file: file1
#
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/git_hug/.git/COMMIT_EDITMSG" 17L, 520C

编辑它, 把 coommit 改成 commit

First commit# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Fri Jun 29 11:35:05 2018 +0800
#
# interactive rebase in progress; onto a632e3d
# Last command done (1 command done):
# r 4f1341a First commit
# Next command to do (1 remaining command):
# pick d30bc00 Second commit
# You are currently editing a commit while rebasing branch 'master' on 'a632e3d'.
#
# Changes to be committed:
# new file: file1
#
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
-- INSERT --

然后 😡 保存, 跳到

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

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

ddmobadeMac-mini:git_hug ddmoba$ git log
commit 1f929783b1acb295aaf7b9dbe500629a1054484f (HEAD -> master)
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 Second commitcommit ea3efe310a6a03a232171bf664401f62a5dc024e
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 First commitcommit a632e3dfa31a06bcec9395c0690d43a3f2f09706
Author: hangj <hangj@protonmail.com>
Date: Fri Jun 29 11:35:05 2018 +0800 Initial commit
ddmobadeMac-mini:git_hug ddmoba$

done !!

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,115
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,587
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,433
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,204
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,839
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,925