[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 ...
随机推荐
- 区间dp之 "石子合并"系列(未完结)
A. 石子合并<1> 内存限制:128 MiB 时间限制:1000 ms 标准输入输出 题目类型:传统评测 方式:文本比较 题目描述 有N堆石子排成一排(n<=100),现要将石 ...
- gcc5+opencv4.0.1 "玄学"bug记录
近期需要使用OpenCV中的gpu加速的一些函数,需要重新编译OpenCV库文件. 由于本机安装的cuda9.0对编译器gcc的版本有要求,平时常用的gcc7.0用不了,所以选用了gcc5.5 . O ...
- 数位dp详解&&LG P2602 [ZJOI2010]数字计数
数位dp,适用于解决一类求x~y之间有多少个符合要求的数或者其他. 例题 题目描述 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除 ...
- Python-基础-文件操作-随机存取
随机存取 文件操作中,read()和write()都属于顺序存取,只能按顺序从头到尾的进行读写.实际上我们可以只访问文件中我们感兴趣的部分.对此,我们可以使用seek()和tell()方法.两种方法的 ...
- Djangon简介
目录 Djangon简介 MVC与MTV模型 MVC MTV python三大主流web框架 Django的下载与基本命令 基于Django实现的一个简单示例 Django静态文件配置 Django ...
- 【sublime Text】关闭sublime的更新提醒和激活提醒
下载了原版的sublime Text,未激活的,每次启动都会提醒要去更新么?需要激活吧 ? 超级烦.[谁让没有激活呢?] 那没办法 ,激活吧! Help ---- Enter License--> ...
- oracle创建用户表空间
--本次因工作需要,为其他部门提供部分表数据,创建一个新用户与表空间.--system用户下drop user sys_outside cascade;drop tablespace sys_outs ...
- asp.net 13 缓存,Session存储
1.缓存 将数据从数据库/文件取出来放在服务器的内存中,这样后面的用来获取数据,不用查询数据库,直接从内存(缓冲)中获取数据,提高了访问的速度,节省了时间,也减轻了数据库的压力. 缓冲空间换时间的技术 ...
- ef core schema 指定架构
不知道很少使用Schema模型还是怎么,居然搜帖子没人说,虽然很简单但是还是想记录一下坑 命名空间 using System.ComponentModel.DataAnnotations.Schema ...
- linq to xml运用示例
代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...