您现在的位置是:网站首页> 编程资料编程资料
git revert和git reset的区别详解_linux shell_
2023-05-26
381人已围观
简介 git revert和git reset的区别详解_linux shell_
git revert和git reset的区别
git revert 是生成一个新的提交来撤销某次提交,此次提交之前的commit都会被保留
git reset 是回到某次提交,提交及之前的commit都会被保留,但是此次之后的修改都会被退回到暂存区
具体一个例子,假设有三个commit, git st:
commit3: add test3.c
commit2: add test2.c
commit1: add test1.c
当执行git revert HEAD~1时, commit2被撤销了
git log可以看到:
revert "commit2":this reverts commit 5fe21s2...
commit3: add test3.c
commit2: add test2.c
commit1: add test1.c
git status 没有任何变化
如果换做执行git reset --soft(默认) HEAD~1后,运行git log
commit2: add test2.c
commit1: add test1.c
运行git status, 则test3.c处于暂存区,准备提交。
如果换做执行git reset --hard HEAD~1后,
显示:HEAD is now at commit2,运行git log
commit2: add test2.c
commit1: add test1.c
运行git st, 没有任何变化
另外:
git revert
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关内容
- linux 随机密码生成工具mkpasswd详解及实例_linux shell_
- shell 批量压缩指定目录及子目录内图片的方法_linux shell_
- 完美解决mac环境使用sed修改文件出错的问题_linux shell_
- shell 使用数组作为函数参数的方法(详解)_linux shell_
- linux 中open()函数详解及简单实例_linux shell_
- Linux 中C语言getcwd()函数的用法_linux shell_
- linux crontab 实现每秒执行的实例_linux shell_
- crontab每10秒执行一次的实现方法_linux shell_
- 基于shell的if和else详解_linux shell_
- Vim中列出TODO与FIXME等备注的方法_linux shell_
