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 ...
随机推荐
- WPF 皮肤之MathApps.Metro UI库
在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...
- 第二篇:gradle脚本运行环境分析(gradle的语义模型)
引言:通过上一篇的论述,我们知道gradle脚本是如假包换的groovy代码,但是这个groovy代码是运行在他的上下文环境里面的,学名叫语义模型.这一篇我们就来看看他的语义模型到底是什么,如何使用. ...
- VIEW层AJAX提交表单到Controller的实体
在MVC环境中,AJAX方式添加一个对象,这个对象在Models中是一个视图模型,在前台显示时是这样的代码: <%using (Html.BeginForm()) { %> ...
- 0基础学习ios开发笔记第一天
Ios操作 界面操作 快捷键 command + c 复制 command+v 粘贴 command +a 全选 command +s 保存 command +z 撤销 command +x 剪切 ...
- IOS_视图实现圆角效果的三种方法及比较
通过代码,至少有三种方法可以为视图加上圆角效果.附例子:https://github.com/weipin/RoundedCorner 方法一.layer.cornerRadius 第一种方法最简单, ...
- Xcode 7 支持http请求info.plist设置
由于iOS9改用更安全的https,为了能够在iOS9中正常使用http发送网络请求,请在"Info.plist"中进行如下配置,否则影响SDK的使用. 1.找到项目中的 Info ...
- c#泛型方法重载
这里存在普通的方法Foo和泛型方法Foo,如果直接调用: 则会自动优先匹配对应的非泛型方法.输出如下: 但需要注意的是,这一匹配过程是在编译过程进行的,所以如果是通过其它泛型间接调用.则只会调用对应的 ...
- java新手笔记7 找最小、最大、排序
1.最小数 // 1.0 public class SortDemo1 { public static void main(String[] args) { int[] a = {2,5,4,6,8, ...
- IDE开发<LER-Studio>(1)::UI设计
LER-Studio主要使用Microsoft Ribbon界面(fluentUI),大致为Office 2007 black. 首先创建MFC程序,基于多文档视图,Ribbon界面,基类选择CVie ...
- rpm命令详解
http://www.rpm.org/max-rpm/s1-rpm-install-additional-options.html#S2-RPM-INSTALL-REPLACEFILES-OPTION ...