Going Back to a Previous Git Commit in Xcode

March 12th, 2018

Filed under: Version Control, Xcode | Be the first to comment!

Something that can happen to you when using version control is you commit a change to the version control repository, realize you made a mistake, and want to go back to an earlier commit. How do you do this in Xcode?

Xcode provides no direct way to go back to an earlier commit. What you have to do is create a branch off the earlier commit and work off that branch.

Open the source control navigator by choosing View > Navigators > Show Source Control Navigator. Select the current branch from the source control navigator. The Xcode editor shows all the commits for that branch.


Select the commit you want to use, right-click, and choose Branch from CommitNumber. The commit number is a long hexadecimal number. Name the branch and click the Create button. Now you’re working from the earlier commit.

Tired of Losing Work?

Have you ever saved a source code file and wish you could go back to the way it was before you saved? Have you ever accidentally deleted files from an Xcode project? Have you ever lost work due to Xcode crashing? If you answered Yes to any of these questions, I can help you.

I’m writing a book, Version Control for iOS and Mac Developers. As the title indicates, it’s a book about version control for iOS and Mac developers. In the book you’ll learn how to place your Xcode projects under version control to minimize the chances of you losing important work. You’ll also learn how to put your projects on GitHub and Bitbucket so you can easily work on projects with other people and create branches so you can build new features without breaking working code. The book also contains exercises for working with version control so you can practice using version control before using it in your own projects.

Sign up for my newsletter to get version control tips, access sneak peeks from the book, and get the chance to buy the book at a discount when it’s finished.

I want to learn more about version control


Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *