[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 ...
随机推荐
- [转帖]CentOS7安装xrdp(windows远程桌面连接linux)
CentOS7安装xrdp(windows远程桌面连接linux) https://blog.csdn.net/sgrrmswtvt/article/details/81869208 You Konw ...
- hanlp添加自定义字典的步骤介绍
本篇分享一个hanlp添加自定义字典的方法,供大家参考! 总共分为两步: 第一步:将自定义的字典放到custom目录下,然后删除CustomDicionary.txt.bin,因为分词的时候会读这 ...
- Plsql配置后,sql语句可以简写 快速使用
in=INSERT up=UPDATE se=SELECT fr=FROM wh=WHERE or=ORDER BY de=DELETE df=DELETE FROM sf=SELECT * FROM ...
- ARST 第五周打卡
Algorithm : 做一个 leetcode 的算法题 /////////////////////////////////////////////////////////////////// // ...
- STL pair 常见用法详解
<算法笔记>学习笔记 pair 常见用法详解 //pair是一个很实用的"小玩意",当想要将两个元素绑在一起作为一个合成元素, //又不想因此定义结构体时,使用pair ...
- 【动态规划】subsequence 1
题目链接:https://ac.nowcoder.com/acm/contest/885/G 题意: 两个串,s t,求s的所有子串中大于 t 的数目 题解: dp[i][j] 表示 s的前i个, ...
- bat 将war文件转换成ear文件
1.无需拷贝war文件,自动获取war set path=%path%;D:\jdk\jdk1.6.0_31\bin;C:\Program Files\7-Zip del **0001-control ...
- 如何用Mvc实现一个列表页面-异步加载
在接触Mvc后,开始有点觉得很累,什么都要自己做,完全没有WebForm的易用性: 大概用了一个月左右的时候,越用用顺手,就习惯了MVC的这种开发方式,灵活,简洁: 当初学习MVC,网上看资料,都是讲 ...
- GridView直接打印
/// <summary> /// 打印功能 /// </summary> /// <param name="panel">打印控件</p ...
- 基于APR模式的Tomcat8环境部署
1.版本信息 组件名 版本号 jdk 1.8.111 tomcat 8.5.9 apr 1.6.3 apr-iconv 1.2.2 apr-util 1.6.2 tomcat-native 1.2.1 ...