Question

Xcode now have built-in version control system. how I can check out older version of my current project in a different location?

Thanks

Was it helpful?

Solution

You are looking at two steps here:

  1. Cloning the repository.
  2. Checking out an older revision.

Cloning the repository

This is pretty straightforward through the steps in Xcode's documentation (look for "Clone or Check Out a Copy of a Project to Use Locally").

Let's say that we start with a project called "Foo" with a repository created by Xcode. I have already done this and made a couple commits. In the Repository Organizer (Command-Shift-2, followed by switching to the "Repositories" tab) I can see Foo listed on the left side. To clone this repository, click the plus sign at the bottom left of the window (shown below).

Repositories organizer.

Per Apple's instructions, I select "Checkout or Clone Repository...". In the next view I provide the complete path to Foo's repository and continue through the steps. Ultimately, I have two copies of "Foo" in the Repositories Organizer.

Checking out an older revision

Let's assume for the answer that you are using Git.

This question and this question both indicate that checking out a specific revision is not supported in Xcode. You can do it pretty easily in the terminal.

In the screenshot below you can see the commit log of my repository shown in the Repositories Organizer. Commit a04ae8d14d13 is the current HEAD of the repository. Let's say that I want to check out commit ea09c358d44f.

Commit log.

To do this, I open a terminal, cd into /Users/David/Documents/Projects/Foo2 and do git checkout ea09c358d44f. After doing that, you can update the Repository Organizer and see the new view of the commit log.

Commit log after checkout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top