博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何撤消当前提交
阅读量:6860 次
发布时间:2019-06-26

本文共 1312 字,大约阅读时间需要 4 分钟。

 

Careful: git reset --hard WILL DELETE YOUR WORKING DIRECTORY CHANGES. Be sure tostash any local changes you want to keep before running this command.

Assuming you are sitting on that commit, then this command will wack it...

git reset --hard HEAD~1

The HEAD~1 means the commit before head.

Or, you could look at the output of git log, find the commit id of the commit you want to back up to, and then do this:

git reset --hard 

If you already pushed it, you will need to do a force push to get rid of it...

git push origin HEAD --force

However, if others may have pulled it, then you would be better off starting a new branch. Because when they pull, it will just merge it into their work, and you will get it pushed back up again.

If you already pushed, it may be better to use git revert, to create a "mirror image" commit that will undo the changes. However, both commits will be in the log.


FYI -- git reset --hard HEAD is great if you want to get rid of WORK IN PROGRESS. It will reset you back to the most recent commit, and erase all the changes in your working tree and index.


Lastly, if you need to find a commit that you "deleted", it is typically present in git reflog unless you have garbage collected your repository.

http://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git

 

转载地址:http://qgtyl.baihongyu.com/

你可能感兴趣的文章
简单了解JS中的几种遍历
查看>>
少走弯路的10条忠告
查看>>
一个多maven项目聚合的实例
查看>>
Mac终端解压命令集合
查看>>
事务日志已满,原因为“ACTIVE_TRANSACTION”
查看>>
linux 按照端口一句命令杀死进程,按照进程名称一句命令杀死进程
查看>>
The last packet sent successfully to the server was 0 milliseconds ago.[nutch---mysql ]
查看>>
win10初期版本administrator的限制
查看>>
使用LVS实现负载均衡原理及安装配置详解
查看>>
Laravel 5使用Laravel Excel实现Excel/CSV文件导入导出的功能详解
查看>>
linux异步IO--aio
查看>>
Installing Hyperledger Fabric v1.1 on Ubuntu 16.04 — Part I
查看>>
sql--CONVERT、FOR XML PATH解决实际问题
查看>>
WPF - 模板查看工具:Show Me The Template及如何查看第三方主题
查看>>
Unix lrzsz命令 上传本地文件到服务器 / 发送文件到客户端
查看>>
JQuery -- this 和 $(this) 的区别
查看>>
PostgreSQL 连接问题 FATAL: no pg_hba.conf entry for host
查看>>
Android 6.0运行时权限第三方库的使用-----RxPermissions
查看>>
leetcode 100. Same Tree
查看>>
搜狗拼音输入法 V9.1.0.2589 最新去广告精简优化版
查看>>