首页 > 其他 > 详细

[Git] How to revert one file changes from one commit

时间:2019-05-17 23:32:45      阅读:194      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/Answer1215/p/10884024.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!