问题
Let's say I have 5 local commits:
- commit 1
- commit 2
- commit 3
- commit 4
- commit 5
At this point when I'm working, I'd like to go back to commit 2.
How would I do so?
This was so easy using snapshots in previous versions of Xcode.
"Discard changes" only goes back to commit 5, right?
回答1:
In Xcode 9:
- Choose Source Control navigator.
- Select (branch) committed project.
- Click "Editor->Checkout ...", or click "Editor->Branch->Checkout ..."
This works for me, it restores the entire project at once.
回答2:
You need to
git checkout COMMIT_2_ID
More info in this answer:
https://stackoverflow.com/a/4114122/1163930
回答3:
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.
来源:https://stackoverflow.com/questions/43669388/how-do-i-restore-from-a-previous-commit-on-xcode-8