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. swift入门-day01

    Swift 简介 简介 Swift 语言由苹果公司在 2014 年推出,用来撰写 OS X 和 iOS 应用程序 2014 年,在 Apple WWDC 发布 历史 2010 年 7 月,苹果开发者工 ...

  2. UIPanGestureRecognizer的使用

    UIGestureRecognizer是一个定义基本手势的抽象类,具体什么手势,在以下子类中包含: 1.拍击UITapGestureRecognizer (任意次数的拍击)      2.向里或向外捏 ...

  3. 【笔记】mongodb启动不了:child process failed, exited with error number 100

    今天在启动mongodb的时候,发现起不来,报错:child process failed, exited with error number 100然后先去/var/log/mongo/mongod ...

  4. Codevs 3729 飞扬的小鸟

    飞扬的小鸟 标签 动态规划 NOIp提高组 2014 难度 提高+/省选- 题目描述 Flappy Bird 是一款风靡一时的休闲手机游戏.玩家需要不断控制点击手机屏幕的频率来调节小鸟的飞行高度,让小 ...

  5. PAT_1002 写出这个数

    宝宝不开心了.自从回家开始百练就上不去POJ也上不去,今天突然HDU也上不去了,PAT25分的题目都快更新完了.我就按顺序往下面更新了.回学校之后题目质量能高出不少= =. 问题描述: 读入一个自然数 ...

  6. (转)怎么去掉Xcode工程中的某种类型的警告 Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32

    问题描述  在我们的项目中,通常使用了大量的第三方代码,这些代码可能很复杂,我们不敢改动他们,可是作者已经停止更新了,当sdk升级或者是编译器升级后,这些遗留的代码可能会出现许许多多的警告,那么我们有 ...

  7. log4j使用细节

    问题一:打印不同类的类名信息? 在log4j中通常是通过Logger.getLogger(class)指定所打印的类名,但是当我们需要打印不同类信息时,目前只能这样做,在不同的类文件中构建不同的log ...

  8. 负载均衡集群中的session解决方案

    前言 在我们给Web站点使用负载均衡之后,必须面临的一个重要问题就是Session的处理办法,无论是PHP.Python.Ruby还是Java,只要使用服务器保存Session,在做负载均衡时都需要考 ...

  9. php对象的高级特性

    对象比较,当同一个类的两个实例的所有属性都相等时,可以使用比较运算符==进行判断,当需要判断两个变量是否为同一个对象的引用时,可以使用全等运算符===进行判断. class Car { } $a =  ...

  10. php返回json数据函数实例

    本文实例讲述了php返回json数据函数的用法,分享给大家供大家参考.具体方法如下: json_encode()函数用法: ? 1 echo json_encode(array('a'=>'bb ...