简体   繁体   English

git undo只更改提交中的某些文件

[英]git undo only changes to some files in a commit

What are best practices to accomplish this task: 完成此任务的最佳实践是:

I have commits: 我有提交:

A -- B -- C

Commit B consist of: 提交B包括:

file1.java
file2.java
icon.png

I would like to undo changes to file1 and file2 but not to icon.png . 我想撤消对file1file2更改,但不能撤消对icon.png更改。

You can stage a revert of commit B and then reset the image file before committing. 您可以暂存提交B的恢复,然后在提交之前重置映像文件。

# Prepare a revert of B
git revert -n B

# Recover the current version of the image
git checkout HEAD -- icon.png

# Commit the "almost" reversion of B
git commit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM