git撤销提交到remote的commit
Reseting remote to a certain commit
Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do:
git reset --hard <commit-hash>
git push -f origin master
However, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes.
In that case, it would be better to revert the commits that you don't want, then pushing as normal.
Update:
you've explained below that other people have pulled the changes that you've pushed,
so it's better to create a new commit that reverts all of those changes.
There's a nice explanation of your options for doing this in this answer from Jakub Narębski.
Which one is most convenient depends on how many commits you want to revert, and which method makes most sense to you.
Since from your question it's clear that you have already used git reset --hard to reset your master branch,
you may need to start by using git reset --hard ORIG_HEAD to move your branch back to where it was before.
(As always with git reset --hard, make sure that git status is clean, that you're on the right branch
and that you're aware of git reflog as a tool to recover apparently lost commits.)
You should also check that ORIG_HEAD points to the right commit, with git show ORIG_HEAD.
总结:
如果你推送到remote的commit没有被其他人pull过,那么你可以使用
git reset --hard <commit-hash>
git push -f origin master
来撤销之前提交的commit
但是如果有其他人同步过你的push,那么你可以在本地使用revert来还原你提交的commit,然后生成一个新的commit然后再推送到远端
git撤销提交到remote的commit的更多相关文章
- git 撤销提交的文件
一.问题 近期在使用git时遇到一个问题,就是在git上传文件时,将一个100兆的大文件添加到了git,并执行了push操作,这时在上传完毕后,会提示这个错误 Large files detected ...
- Git CMD连接,管理(remote,add,commit,push)github repository
git initmd testcd testgit statusgit add test //git add test/a.txtgit status git remote add origin g ...
- git tag、gitignore和git撤销提交
前言 最近在git的使用过程中遇到了一些新的问题,所以写下来方便自己回忆. git tag 打标签 git tag -a v1.00 -m "注释" git tag 打标签命令 - ...
- git撤销提交(commit)
我们知道Git有三大区(工作区.暂存区.版本库)以及几个状态(untracked.unstaged.uncommited) 一.简介 Git 保存的不是文件的变化或者差异,而是一系列不同时刻的文件快照 ...
- Git撤销提交
本文链接:http://volnet.github.io/#!docs/git/reset-to-old-version.md 在使用Git进行版本管理的时候,经常会遇到一些错误的提交. 在开始演示之 ...
- Git撤销提交和修改相关操作
团队开发中经常遇到错误删除文件,错误提交等情况,那么使用Git该如何正确的进行撤销和恢复呢? 一.增补提交 git commit –C HEAD –a --amend -C表示复用指定提交的提交留言, ...
- git 撤销上一次 commit
1.本地 commit,没有推到远程仓库 可以 git reset --soft <commit_id>,commit_id 是要回退到的某一版本 然后再进行修改,再commit, 如果需 ...
- Git 撤销所有未提交(Commit)的内容
撸了好多代码,但是突然设计改了(~~o(>_<)o ~~):或者引入个第三方库,后来又发现用不着,想删掉,但文件太多了(比如几百个):那,怎么办呢,都不想了...Git 比人聪明,所以能很 ...
- Git撤销对远程仓库的push&commit提交
撤销push 1. 执行 git log查看日志,获取需要回退的版本号 2. 执行 git reset –soft <版本号> ,如 git reset -soft 4f5e9a90ed ...
随机推荐
- Openfire:安装指南
本文的英文原文来自 http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/install-guide.html ...
- ssh(Struts2+hibernate+spring)简单分页
实体类+实体映射+entity(pagebean)+dao层+service层+action层
- C++里容易忽视却不能忽视的
1 define 只是简单地文本替换. 2 每个机器的字长不同. 3 每个类型在不同的机器上,所占用的内存空间不同. 4 每个机器内部的字节大小端不同. 5 并不是所有的编译器或机器都支持最新的C++ ...
- 一段sql的优化
优化前代码 select * ,ROW_NUMBER() OVER(order by WrongCount desc) as rowId from(select Quba_IDint,Quba_Num ...
- 自己动手丰衣足食,h5手机端jquery弹窗插件(事件冒泡、单例模式、遮盖部分禁止默认滚动)
感谢浏览,欢迎交流=.= 公司开发微信网页多处需要使用弹窗,使用jquery-ui的定制化下载仍需要150多kb,想来有些奢侈(最终下来只有11kb,压缩后2kb,啊,我的神), 手机端弹窗方式与pc ...
- WebStorm快捷键收集
1.webstorm快捷键: IntelliJ-Idea 的快捷键 Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/*…*/ ) Shift+F6 重构-重命名 Ctrl+X 删除行 C ...
- PHP curl 采集内容之规则 1
<?phpheader("Content-type:text/html; charset=utf-8");$pattern = '/xxx(.*)yyyy/isU'; //i ...
- CSS 常用命名
在前端开发中,规范使用 DIV+CSS 命名,可以增强团队合作提高开发效率,有利于页面后期的维护和优化. 1.页面结构 wrap:外套.包裹,用于最外层. wrapper:外套,用于页面外围控制整体布 ...
- 青瓷qici - H5小游戏 抽奖机 3 效果设置
现在是万事俱备,只欠东风,好,我们一起动手,先来东风东. 烟花粒子效果 第一个来实现我们的烟花粒子效果,点击我们的粒子,按照下图方式配置. 注意此时我们已经加入了white.png作为粒子特效使用. ...
- AppDomain(1)-AppDomainSetup