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的更多相关文章

  1. git 撤销提交的文件

    一.问题 近期在使用git时遇到一个问题,就是在git上传文件时,将一个100兆的大文件添加到了git,并执行了push操作,这时在上传完毕后,会提示这个错误 Large files detected ...

  2. 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 ...

  3. git tag、gitignore和git撤销提交

    前言 最近在git的使用过程中遇到了一些新的问题,所以写下来方便自己回忆. git tag 打标签 git tag -a v1.00 -m "注释" git tag 打标签命令 - ...

  4. git撤销提交(commit)

    我们知道Git有三大区(工作区.暂存区.版本库)以及几个状态(untracked.unstaged.uncommited) 一.简介 Git 保存的不是文件的变化或者差异,而是一系列不同时刻的文件快照 ...

  5. Git撤销提交

    本文链接:http://volnet.github.io/#!docs/git/reset-to-old-version.md 在使用Git进行版本管理的时候,经常会遇到一些错误的提交. 在开始演示之 ...

  6. Git撤销提交和修改相关操作

    团队开发中经常遇到错误删除文件,错误提交等情况,那么使用Git该如何正确的进行撤销和恢复呢? 一.增补提交 git commit –C HEAD –a --amend -C表示复用指定提交的提交留言, ...

  7. git 撤销上一次 commit

    1.本地 commit,没有推到远程仓库 可以 git reset --soft <commit_id>,commit_id 是要回退到的某一版本 然后再进行修改,再commit, 如果需 ...

  8. Git 撤销所有未提交(Commit)的内容

    撸了好多代码,但是突然设计改了(~~o(>_<)o ~~):或者引入个第三方库,后来又发现用不着,想删掉,但文件太多了(比如几百个):那,怎么办呢,都不想了...Git 比人聪明,所以能很 ...

  9. Git撤销对远程仓库的push&commit提交

    撤销push 1. 执行  git log查看日志,获取需要回退的版本号 2. 执行 git reset –soft <版本号> ,如 git reset -soft 4f5e9a90ed ...

随机推荐

  1. DI(依赖注入)简单理解 NO1

    依赖注入:目的削减程序的耦合度,达到高内聚/低耦合 常用形式:Interface Driven Design接口驱动,接口驱动有很多好处,可以提供不同灵活的子类实现,增加代码稳定和健壮性等等.通过Io ...

  2. spring定时任务的配置

    定时任务配置分为三个步骤: 1.定义任务 2.任务执行策略配置 3.启动任务 1.定义任务 <!--要定时执行的方法--> <bean id="testTaskJob&qu ...

  3. DbUtil组件及C3P0数据库连接池组件的使用

    DbUtils 是 Apache 组织提供的一个开源 JDBC工具类库,它是对JDBC的简单封装,学习成本极低,并且使用dbutils能极大简化jdbc编码的工作量,同时也不会影响程序的性能. 使用c ...

  4. 自己在使用的English词典

    一.ESL/非母语词典 二.EFL/母语词典 1.American Heritage Dictionary 2.World Book Dictionary 3.Oxford Dictionary of ...

  5. Greedy is Good

    作者:supernova 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=greedyAlg Joh ...

  6. 高性能网络I/O框架-netmap源码分析

    from:http://blog.chinaunix.net/uid-23629988-id-3594118.html 博主这篇文章写的很好 感觉很有借签意义 值得阅读 高性能网络I/O框架-netm ...

  7. JS将时间戳转换为JS Date类型

    /*将JSON Date 格式转换为JavaScript 的Date 类型JSON Date 格式:"/Date(146471041000)/"*/function JSONDat ...

  8. #Leet Code# Populating Next Right Pointers in Each Node II

    描述:注意需要先self.connect(right)再self.connect(left),否则会有case通不过,原因是左边递归执行时依赖与右边的next已经建立,而先执行connect(left ...

  9. 转载“用USBOOT制作DOS启动盘”

    使用软件: Usboot和MaxDOS_5.6s_U盘版. 由于我的U盘容量比较小,暂时只能做DOS启动功能,其它功能如Windows PE,等我以后测试成功后再补充说明. U盘是啥? 读音优盘,可以 ...

  10. 从 IT 的角度思考 BIM(一):面向对象

    还记得那个笑话吗:要把大象放进冰箱,总共分几步?这不仅仅是一个笑话,还是一个值得我们好好分析的笑话. 如果要放进冰箱的是一个苹果,那么也就不可笑了,但换成大象,就引起了我们的兴趣和注意,为什么? 我们 ...