[Git] How to revert one file changes from one commit
Many times we might changed one file which we don't intent to do... but it was too late, until we found it, it is already push to repo.
Let's assume,
First, we checkout a feature branch, we have two files:
a.txt:
Init a
b.txt:
Init b
This is original state. Let's assign a commit id: a111.
Now we made a mistake, we changed a.txt by mistake, in the mean while we are also doing some work in b.txt:
a.txt:
I don't know this changes
b.txt:
I want to keep this changes
You can have as many commit as you want:
...
Now we found that a.txt shouldn't be changed
git checkout a111 src/a.txt // checkout <commit id> <filename>
git status
git add .
git commit -am "revert a.txt"
git push

[Git] How to revert one file changes from one commit的更多相关文章
- bin sh git@github.com no such file or directory
window下使用git: 输入命令:git clone git @github.com:Alan0521/dotvim.git 出现/bin/sh:git@github.com no such fi ...
- Git提交时提示‘The file will have its original line endings in your working directory’
Git提交时提示'The file will have its original line endings in your working directory' Git出现错误 git add -A ...
- Git 使用revert回滚已提交的commit
在git使用中如果提交错误的代码至远程服务器,可以使用git revert 命令回滚单次commit并且不影响其他commit. 回滚最新一次的提交记录: git revert HEAD 回滚前一次的 ...
- git error: unable to create file Invalid argument
git error: unable to create file xxxx Invalid argument 原因: mac 上创建的文件名里有冒号,这在windows 上是不允许的. 解决方式: ...
- 理解LGWR,Log File Sync Waits以及Commit的性能问题[转]
理解LGWR,Log File Sync Waits以及Commit的性能问题 一.概要: 1. Commit和log filesync的工作机制 2. 为什么log file wait太久 3. ...
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突 这篇是接着上篇分布式版本库--Windows下G ...
- Git reset head revert 回滚
Overview 涉及Git一些日常操作 :) 基础知识 <Pro Git>至少了解branch,commit的概念,及基本的原理 Git常用魔法 存档:master代码回滚方法 我是QA ...
- git 提交报错 : The file will have its original line endings in your working directory.
报错现象 git add . 的时候发现此报错 报错分析 看情况应该是不同系统对换行的识别不到位导致的 就常识来说文件是在windows下生成的所以换行和 linux 确实不同可能是因为这个导致的 ...
- git操作中出现Unlink of file '......' failed. Should I try again?
在操作git中有时候会提示 Unlink of file '......' failed. Should I try again? 原因是你工作目录有某些文件正在被程序使用,这个程序多半是Idea,V ...
随机推荐
- Android的视图(View)组件
Android的绝大部分UI组件都放在android.widget包及其子包.android,view包及其子包中,Android应用的所有UI组件都继承了View类,View组件非常类似于Swing ...
- X-UA-Compatibles
今天在看京东网页代码的时候,发现了X-UA-Compatibles 这个元信息属性,不是很清楚,百度了一下,做下记录 X-UA-Compatible 属性是 IE 浏览器在 IE8 版本开始提供的一个 ...
- 图解django的生命周期
其实django的生命周期的大体框架就是这样,剩下的细致的,自己再补充! 图片实在是有点抽象! 谅解!! koala-----给你更多技术小干货
- vue 动态添加对象属性
昨天使用vue发现直接给对象添加属性,并不能触发响应更新,后来看文档发现要通过this.$set 函数动态添加才可用,eg: this.$set( obj, key, data)
- Resource Model
API不应该直接返回Entity,应该是返回一个Resource,不想把entity内部的细节暴漏给外部 viewModel是在MVC中的叫法 使用AutoMapper来对Entity和Resourc ...
- 养成一个SQL好习惯
要知道sql语句,我想我们有必要知道sqlserver查询分析器怎么执行我么sql语句的,我么很多人会看执行计划,或者用profile来监视和调优查询语句或者存储过程慢的原因,但是如果我们知道查询分析 ...
- javascript是一种安全语言
一.简单JavaScript是一个基于Java基本语句和控制流的简单而紧凑的设计,这是学习Java的一个很好的过渡.它的变量类型是弱类型,而不是严格的数据类型.二.力学JavaScript是动态的,可 ...
- JS中有两种自加法操作
JS中有两种自加法操作.它们的运算符是++,它们的函数是向1添加运算符. 我和我的区别在于操作的顺序和组合的方向. 其中:++var被称为预自动添加,变量执行自动添加操作后.它的操作是先执行自动加法操 ...
- 微信小程序点击复制功能
wx.setClipboardData({ data: '这是要复制的文字', success: function (res) { wx.showModal({ title: '提示', conten ...
- java 读取property
Properties prop = new Properties(); String path = AlarmController.class.getResource("/").g ...