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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Git 使用revert回滚已提交的commit

    在git使用中如果提交错误的代码至远程服务器,可以使用git revert 命令回滚单次commit并且不影响其他commit. 回滚最新一次的提交记录: git revert HEAD 回滚前一次的 ...

  4. git error: unable to create file Invalid argument

    git error: unable to create file xxxx  Invalid argument 原因: mac  上创建的文件名里有冒号,这在windows 上是不允许的. 解决方式: ...

  5. 理解LGWR,Log File Sync Waits以及Commit的性能问题[转]

    理解LGWR,Log File Sync Waits以及Commit的性能问题 一.概要: 1.  Commit和log filesync的工作机制 2.  为什么log file wait太久 3. ...

  6. Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突

    Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突 这篇是接着上篇分布式版本库--Windows下G ...

  7. Git reset head revert 回滚

    Overview 涉及Git一些日常操作 :) 基础知识 <Pro Git>至少了解branch,commit的概念,及基本的原理 Git常用魔法 存档:master代码回滚方法 我是QA ...

  8. git 提交报错 : The file will have its original line endings in your working directory.

    报错现象 git  add . 的时候发现此报错 报错分析 看情况应该是不同系统对换行的识别不到位导致的 就常识来说文件是在windows下生成的所以换行和 linux 确实不同可能是因为这个导致的 ...

  9. git操作中出现Unlink of file '......' failed. Should I try again?

    在操作git中有时候会提示 Unlink of file '......' failed. Should I try again? 原因是你工作目录有某些文件正在被程序使用,这个程序多半是Idea,V ...

随机推荐

  1. windows登录密码忘记了怎么办?

    利用PE工具进行进行修改密码或者重置系统密码,正对于服务器也同样试用 目前U启动制作效果还不错,黑鲨一键装机,以及老毛桃我觉得还是算了,U深度也不错 经过这么久,小编也把该测试的测试了,,小编比较懒, ...

  2. Linux系列(7):入门之磁盘与文件系统管理

    1.磁盘的主要概念 下面展示一下磁盘结构图: 1.磁道 2.柱面 3.物理扇区 已经了解了这么多概念,现在总结一下 4.磁盘分区 1.概念 磁盘分区就是将磁盘划分成不同的区域. 2.分区的最小单位 早 ...

  3. JavaScript--QuckStudy

    Day1: 初识JS: https://www.liaoxuefeng.com/wiki/1022910821149312 >打印: alert('我要学JavaScript!'); >J ...

  4. T100——按xls格式批量导入数据

    弹出File Browser窗口 PRIVATE FUNCTION cxrt020_open_file() DEFINE l_dir LIKE type_t.chr500 DEFINE r_succe ...

  5. Spring Boot源码分析-配置文件加载原理

    在Spring Boot源码分析-启动过程中我们进行了启动源码的分析,大致了解了整个Spring Boot的启动过程,具体细节这里不再赘述,感兴趣的同学可以自行阅读.今天让我们继续阅读源码,了解配置文 ...

  6. how to Simply Singleton Navigate the deceptively simple Singleton pattern---reference

    http://www.javaworld.com/article/2073352/core-java/simply-singleton.html JAVA DESIGN PATTERNS By Dav ...

  7. Java 反射理解(一)-- Class 类的使用

    Java 反射理解(一)-- Class 类的使用 概念 这里阐述几个基本概念: 在面向对象的世界里,万事万物皆对象.(在 Java 语言中,静态的成员.普通数据类型除外) 类也是对象,类是 java ...

  8. SQL SERVER中Datetime时间的范围与.net的DateTime对象的区别

    对于编写.net程序中我们一般写默认的时间,我们会自动创建一个new DateTime()对象.但与SQL SERVER连用我们就会出现一个时间范围的问题. 今天我就记录一下该时间问题. 我们创建的n ...

  9. MVC4学习要点记三

    一.数据迁移用来解决code first情况下当增加.删除.改变实体类,或改变DbContext类后,相应地更新数据库结构而不会对现有数据产生影响. 1.启用迁移指令:enable-migration ...

  10. centos7--web项目使用远程mysql数据库

    07-django项目连接远程mysql数据库   比如电脑a(ip地址为192.168.0.aaa)想要连接访问电脑b(ip地址为192.168.0.bbb)的数据库: 对电脑a(ip地址为192. ...