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. SQLServer获取最后插入的ID值SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY的比较

    IDENT_CURRENT 返回为任何会话和任何作用域中的特定表最后生成的标识值.IDENT_CURRENT 不受作用域和会话的限制,而受限于指定的表. @@IDENTITY 返回为当前会话的所有作用 ...

  2. 20160427Struts2--入门1

    参考资料来自传智播客:非原创,只是做个笔记: 一.Struts2简介: Struts2是在WebWork2基础发展而来的.和struts1一样, Struts2也属于MVC框架.不过有一点大家需要注意 ...

  3. Sqlserver With as

    with t as (select * from emp where depno=10) 总结:可以看做将查询出来的语句块表示为一个临时表 select * from t where empno=xx ...

  4. win向linux传文件

    使用pscp.exe即可. 下载pscp.exe(http://pan.baidu.com/s/1jG6zmx4) 复制到windows/system32目录下即可. 然后可在cmd命令行下使用psc ...

  5. redis 在windows上运行

    参考自:https://github.com/ServiceStack/redis-windows 1.用vagrant 运行redis的最后版本 1.1在windows上安装vagrant http ...

  6. Constants in C++

    The first motivation for const seems to have been to eliminate the use of preprocessor #define for v ...

  7. ASP.NET一些常用的东西

    三层架构的命名: UI: User Interface (数据显示层 用户界面)BLL:Business Logic Layer (业务逻辑层)DAL:Data Access Layer (数据访问层 ...

  8. ajax跨域访问 webservice

    前端代码 $.ajax({ type: "POST", url: "http://localhost:9767/WebService1.asmx/HelloWorld?j ...

  9. #添加屏蔽IP LINUX

    netfilter/iptables 的最大优点是它可以配置有状态的防火墙,这是 ipfwadm 和 ipchains 等以前的工具都无法提供的一种重要功能.有状态的防火墙能够指定并记住为发送或接收信 ...

  10. ubuntu mint 15 编译安装PHP开发环境

    php 5.3.5(download zip) httpd 2.2.24(download zip) mysql: apt-get install mysql step 1: install mysq ...