我如何将修改的文件转换为以前的修订,在一个特定的 commit hash (我通过 git log 和 git diff 确定)?


当前回答

git log --oneline  // you see commits, find commit hash to which you want reset
git diff y0urhash src/main/.../../YourFile.java   // to see difference
git reset y0urhash src/main/.../../YourFile.java   // revert to y0urhash commit
git status                                        // check files to commit
git commit -m "your commit message"
git push origin

其他回答

如果您在最后的命令中犯下错误的文件,请遵循指示:

开源树,改变这个承诺

此分類上一篇

更改行,并找到你的承诺,错误的文件发送为承诺

此分類上一篇

你可以看到你的更改列表在这个承诺选择它,然后点击... 按钮右侧... 点击逆文件,然后你可以看到它在文件状态选项卡在左侧下方然后点击不步骤:

此分類上一篇

打开您的视觉工作室代码,然后返回,完成您的删除文件之后,您可以在源树上看到您的最后一个承诺的结果。

此分類上一篇

我现在有相同的问题,我发现这个答案是最容易理解的(commit-ref 是您想要返回日志中的变更的 SHA 值):

git checkout [commit-ref] [filename]

这将把旧版本放在你的工作目录中,从那里你可以承诺它,如果你愿意。

git checkout ref♰commitHash -- filePath

吉。

git checkout HEAD~5 -- foo.bar
or 
git checkout 048ee28 -- foo.bar

这里是我的路。

在 Android Studio 中,打开文件。

(b) git -> 显示历史,找到我要转向的以前的承诺。

c) git checkout commit_id file_path

git log --oneline  // you see commits, find commit hash to which you want reset
git diff y0urhash src/main/.../../YourFile.java   // to see difference
git reset y0urhash src/main/.../../YourFile.java   // revert to y0urhash commit
git status                                        // check files to commit
git commit -m "your commit message"
git push origin