我如何将修改的文件转换为以前的修订,在一个特定的 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
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别