How do I restore from a previous commit on Xcode 8?

ε祈祈猫儿з 提交于 2019-12-23 17:48:17

问题


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:

  1. Choose Source Control navigator.
  2. Select (branch) committed project.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!