4

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?

Mestwick
  • 41
  • 1
  • 1
  • 4

3 Answers3

5

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.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
user3537954
  • 51
  • 1
  • 2
3

You need to

git checkout COMMIT_2_ID

More info in this answer:

https://stackoverflow.com/a/4114122/1163930

Community
  • 1
  • 1
Muhammad
  • 335
  • 7
  • 27
1

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.

Varun Pozhath
  • 608
  • 6
  • 19