如何从 Xcode 8 上的先前提交中恢复?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43669388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I restore from a previous commit on Xcode 8?
提问by Mestwick
Let's say I have 5 local commits:
假设我有 5 个本地提交:
- commit 1
- commit 2
- commit 3
- commit 4
- commit 5
- 提交 1
- 提交 2
- 提交 3
- 提交 4
- 提交 5
At this point when I'm working, I'd like to go back to commit 2.
在这一点上,当我工作时,我想回到 commit 2。
How would I do so?
我该怎么做?
This was so easy using snapshots in previous versions of Xcode.
在以前版本的 Xcode 中使用快照非常容易。
"Discard changes" only goes back to commit 5, right?
“放弃更改”只会回到提交 5,对吗?
回答by user3537954
In Xcode 9:
在 Xcode 9 中:
- Choose Source Control navigator.
- Select (branch) committed project.
- Click "Editor->Checkout ...", or click "Editor->Branch->Checkout ..."
- 选择源代码管理导航器。
- 选择(分支)提交的项目。
- 点击“Editor->Checkout...”,或点击“Editor->Branch->Checkout...”
This works for me, it restores the entire project at once.
这对我有用,它可以立即恢复整个项目。
回答by Muhammad
You need to
你需要
git checkout COMMIT_2_ID
git 结帐 COMMIT_2_ID
More info in this answer:
此答案中的更多信息:
回答by Varun Babu Pozhath
You can use the version editor in XCODE to do revert each of your files to the previous version. Go to View > Version Editor > Show Version Editor. There is a timeline icon at the bottom of the split view. You can revert to previous commits.
您可以使用 XCODE 中的版本编辑器将每个文件恢复到以前的版本。转到“查看”>“版本编辑器”>“显示版本编辑器”。拆分视图底部有一个时间线图标。您可以恢复到以前的提交。