我在AndroidStudio3.3中的项目中使用Github。
我发现恢复命令显示在三个位置,请参见图像1、图像2、图像3-1和图像3-2 (图像3-2是图像3-1的详细窗口,还原命令位于图像3-2的左中)。
这三个还原命令有什么不同?
图像1

图像2

图像3-1

图像3-2

发布于 2019-03-05 09:55:54
TLDR:
图1,Version Control -> Log -> Revert,编辑存储库,使其看起来像是提交之前的时间,并且还可以选择提交。
图2,VCS -> Git -> Revert...,删除所选文件的未提交更改。
图3,Local History -> Show History,作用类似于1,但在特定于JetBrains的工具中,与Git无关。
详细信息:
Version Control -> Log -> Revert实际上是这样做的:
- (The `reset` at :29 is just want to restore the Git repository for testing.)
- First, it do a `git revert`, making some edit outside the control of Git, and the repository become dirty (needs to commit).
- Then, pop up a commit window, asking for you to commit.
- Second, after you decided what file to commit, make a `git add` and `git commit`.
- Conclusion: `Version Control` -> `Log` -> `Revert` = `git revert` (+ `git add` + `git commit`, optional ) = Edit the repository like before the commit it is reverted to.
VCS -> Git -> Revert... 才会激活。实际上是这样做的:
- First, it do a `git rm --cached -f`
- Then, it do a `git checkout HEAD`
- Conclusion: `VCS` -> `Git` -> `Revert...` = `git rm` + `git checkout` = Drop any uncommitted changes.
Local History -> Show History 是由IntelliJ IDEA管理的独立内置VCS。 (以及其他JetBrains IDE,包括从IntelliJ IDEA社区获得补丁的Android ),它与Git或其他类型的VCS没有任何关系,如果您执行File -> Invalidate Caches / Restart -> Invalidate,它将被清除。该Revert的作用类似于Version Control -> Log -> Revert,两者都将源恢复到历史记录。发布于 2019-03-03 14:38:39
VCS -> Git -> Revert...不会恢复提交,只会还原本地分阶段的更改。
它相当于git reset HEAD,也就是添加到索引中的非阶段更改。
Log中显示的还原实际上将git revert一个提交,即:创建一个新提交,它将取消由还原提交引入的更改。
https://stackoverflow.com/questions/54945077
复制相似问题