在提交中还原对文件的更改 [英] Revert changes to a file in a commit

查看:11
本文介绍了在提交中还原对文件的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想还原对给定文件的特定提交所做的更改.

I want to revert changes made by a particular commit to a given file only.

我可以使用 git revert 命令吗?

Can I use git revert command for that?

还有其他简单的方法吗?

Any other simple way to do it?

推荐答案

我见过的最简洁的方法是 这里

The cleanest way I've seen of doing this is described here

git show some_commit_sha1 -- some_file.c | git apply -R

类似于 VonC 的响应,但使用 git showgit apply.

Similar to VonC's response but using git show and git apply.

这篇关于在提交中还原对文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆