我如何将修改的文件转换为以前的修订,在一个特定的 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

其他回答

这对我工作:

git checkout <commit hash> file

接下来的改变:

git commit -a

显然,有人需要在 git 上写一本可理解的书,或者 git 需要在文档中更好地解释。

cd <working copy>
git revert master

他们会放弃最后的承诺,似乎正在做。

伊恩

git checkout ref♰commitHash -- filePath

吉。

git checkout HEAD~5 -- foo.bar
or 
git checkout 048ee28 -- foo.bar
git revert <hash>

它听起来像你认为 git revert 只会影响最新的承诺。

它不会解决你的问题,如果你想转换一个更改在一个特定的文件,并承诺更改超过该文件。

执行下列命令,进行软重新设置,变更到您的本地。

git reset --soft HEAD^1

查看您此前承诺的文件的状态,到达您的本地,然后进行更改。

 git status

承诺并按下文件后进行更改. 未来的承诺历史错误的文件将不会显示

在从起源中提取之前,始终保持喷射(可选步骤)

 git remote prune origin