xgqfrms / frontend-interview-quetions-collection

前端面试题集: 初级、中级、高级, 目标 1000 题!🚀
https://frontend-interview-quetions-collection.xgqfrms.xyz
MIT License
2 stars 0 forks source link

Git Tools Rewriting History #1

Open xgqfrms opened 2 years ago

xgqfrms commented 2 years ago

Git Tools Rewriting History

https://www.cnblogs.com/xgqfrms/p/16465388.html

before

image

after

commit 82e51b33256a291259eb2b2a66ef0970eb32ea85 (HEAD -> main, origin/main, origin/HEAD)
Author: xgqfrms <xgqfrms@outlook.com>
Date:   Fri Aug 12 01:37:10 2022 +0800

    Create readme.md

commit 6eb693141613af2febc1cc8defd2e934277e57f5
Author: xgqfrms <xgqfrms@outlook.com>
Date:   Fri Aug 12 01:36:40 2022 +0800

    Create readme.md

commit ccf9cf9def54b96bdd6c4fc2bbd46fc13e198a35
Author: xgqfrms <xgqfrms@outlook.com>
Date:   Fri Aug 12 01:26:40 2022 +0800

    Create readme.md

commit 8c9e87e748f106e3734dc2b1741a6b120cb2cf26
Author: xgqfrms <xgqfrms@outlook.com>
Date:   Fri Aug 12 01:25:55 2022 +0800

    Initial commit
~
image
xgqfrms commented 2 years ago

https://github.com/xgqfrms/frontend-iterview-quetions-collection/commits/main

image

ccf9cf

image

e6d899

e6d899f479ade1ef90d06b5567a5abe964d4a2ae

xgqfrms commented 2 years ago

编辑器 VIM / VI

$ git rebase -i HEAD~3
hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.

# 写入并退出
:wq!

# 写入并强制退出
:wq!

# 强制确认退出
:qa!

作者:xgqfrms 链接:https://www.cnblogs.com/xgqfrms/p/16465388.html 来源:https://www.cnblogs.com 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 ©xgqfrms 2012-2022 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!

xgqfrms commented 2 years ago
image image image

$ git rebase -i HEAD~3
# 等价于
# $ git rebase -i HEAD^2

# 修改 commit
$ git commit --amend

# ???
$ git rebase --continue

$ git push -f
xgqfrms commented 2 years ago
image
# main
$ git log
xgqfrms commented 2 years ago

steps ✅

$ git rebase -i HEAD~3
# 等价于
# $ git rebase -i HEAD^2

# 修改 commit
$ git commit --amend

$ git push -f
image image image image image