当前位置: 首页 > 工具软件 > Git snippet > 使用案例 >

git 重置修改文件_使用git重置文件更改

慕冠宇
2023-12-01

git 重置修改文件

There are many different philosophies when it comes to code review but mine is fairly simple:  I like receiving early "work in progress" patches, I like to be positive in my code review messages, and if a patch is 90% there, I like to finish the patch myself so the project and contributor both benefit.

关于代码审查,有很多不同的理念,但是我的相当简单:我喜欢收到早期的“进行中”补丁,我喜欢对代码审查消息持肯定态度,如果那里有90%的补丁,我喜欢自己完成补丁,这样项目和贡献者都将从中受益。

Every once in while, however, a patch comes in with an unrelated file change or code added to the wrong file, in which case I need to reset a file's contents before the change commit.  You can restore a file's contents before a patch with the following:

但是,每隔一段时间就会发布一个补丁,其中包含不相关的文件更改或将代码添加到错误的文件,在这种情况下,我需要在更改提交之前重置文件的内容。 您可以使用以下命令在修补程序之前还原文件的内容:


git reset origin/master path/to/file-to-be-changed.ext

Once this shell snippet is executed, the file's contents are restored and can be re-commited to restore the file contents.

一旦执行了此shell片段,便会还原文件的内容,并可重新提交以还原文件的内容。

翻译自: https://davidwalsh.name/reset-file-git

git 重置修改文件

 类似资料: