[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 ...
随机推荐
- SQL SERVER DATENAME函数
定义: DATENAME函数返回指定日期的指定部分. 语法: DATENAME(datepart,date) 参数: ①datepart 参数可以是下列的值: datepart 缩写 年(Year) ...
- Java MyBatis逆向工程,自动生成pojo,mapper
生成xml文件,文件名generator.xml <?xml version="1.0" encoding="UTF-8"?><!DOCTYP ...
- 洛谷P2622 关灯问题II (二进制枚举+bfs
题目描述 现有n盏灯,以及m个按钮.每个按钮可以同时控制这n盏灯——按下了第i个按钮,对于所有的灯都有一个效果.按下i按钮对于第j盏灯,是下面3中效果之一:如果a[i][j]为1,那么当这盏灯开了的时 ...
- MySql常用字符集
常用字符集 位(bit):是计算机 内部数据 储存的最小单位,11001100是一个八位二进制数. 字节(byte):是计算机中 数据处理 的基本单位,习惯上用大写 B 来表示,1B(byte,字节) ...
- Elastic Search中normalization和分词器
为key_words提供更加完整的倒排索引. 如:时态转化(like | liked),单复数转化(man | men),全写简写(china | cn),同义词(small | little)等. ...
- 这周末又参加班里同学生日party,同学父母包场2小时花费大约1000美金左右。
今天班上Claire的生日,邀请了几个小朋友去pump it up.特别特别开心,因为她父母选的时间特别好晚上6-8点小孩子玩疯了以后吃的特别多.
- STL之Deque的使用方法
STL 中类 stack 实现了一个栈 1)push 能够插入元素 2)pop 移除栈顶元素 使用的时候,需要包含头文件 #include <stack>,stack 被声明如下: nam ...
- QT编译Mysql驱动问题及解决方案
默认情况下,qt 并没有自带mysql的数据库插件,需要自己编译先安装mysql server ,运行setup.exe时选择自定义安装,安装目录设为"D:\mysqldev"不要 ...
- python 获取当前目录下的文件目录和文件名
python 获取当前目录下的文件目录和文件名 os模块下有两个函数: os.walk() os.listdir() 1 # -*- coding: utf-8 -*- 2 3 import os ...
- LintCode 547---两数组的交集
public class Solution { /** * 给出两个数组,写出一个方法求出它们的交集 * @param nums1: an integer array * @param nums2: ...