Source control workflow

You should use source control to back up your files, collaborate with others, and tag your releases.

If you select “Create Git repository on my Mac” on the last sheet that appears when you create your Xcode project from a template, Xcode automatically creates a local Git repository for your project.

Step 1: Use a local repository

You can create a local source control repository for a new project or an existing project. Later, when you need to share the project or access it from multiple Mac computers, you can create a remote repository for it.

Step 2: Create a remote repository

If you use Bitbucket, GitHub, or GitLab to manage your remote repository, first add the remote repository account in Accounts preferences. To back up your project or share it with others, create a remote from a local source code repository. To check out an existing project, you can clone a project from a remote repository or add an existing remote to your local repository.

Step 3: Pull, commit, and push changes

After you make changes to your project, you can view changes in the source editor or compare revisions of a file. Then commit the changes to the source code repository. For remote repositories, pull changes from a remote repository before you commit, and then push the changes after you commit.

Step 4: View repositories and commits

In the Source Control navigator, choose a branch in your repository and in the history editor, view the commits. You can filter the commits, view the files in the comparison editor, and email the author of a commit.

Step 5: Manages branches and use tags

You can create a branch in a repository to isolate your changes and not impact others. Later, you merge the two branches in a repository together. You can also tag a commit in a branch to easily check it out later. Especially, tag your commits before you distribute your app. You can also create groups in the Tags folder to organize your releases.

See alsoConfigure source control management