如何撤消当前提交
2016-05-13 09:56
253 查看
Careful:
Assuming you are sitting on that commit, then this command will wack it...
The
Or, you could look at the output of
If you already pushed it, you will need to do a force push to get rid of it...
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
FYI --
Lastly, if you need to find a commit that you "deleted", it is typically present in
http://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git
git reset --hardWILL 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~1means 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 <sha1-commit-id>
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 HEADis 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 reflogunless you have garbage collected your repository.
http://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git
相关文章推荐
- html页面高度不同浏览器兼容性设置
- Linux 自动同步服务器时间
- Timer定时器
- Ping百度自动提交网址
- c# Bitmap byte[]互转
- codeforces 672C Recycling Bottles (枚举+贪心)
- 【BZOJ4430】[Nwerc2015]Guessing Camels赌骆驼【树状数组】【或CDQ分治】
- BIO、NIO的区别
- googleNet
- 表单上传文件
- POJ2752 KMP中next数组的应用
- POJ 2785 4 Values whose Sum is 0(折半枚举)
- 蓝桥杯 剪格子(DFS)
- PHP正则表达式教程(基础篇)
- jQ获取浏览器window的高宽
- (转载收藏用)linux sed命令详解
- android studio 配置git,绕过曾经掉下去的坑
- 关于英语前缀和后缀的区别
- C# Base64编码解码
- C++中的引用(&)