Ignoring Files That Are Already in a Git Repository

March 5th, 2018

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

In a previous post, I showed how to tell git to ignore files in Xcode projects. But what do you do if you want to ignore a file that git is currently tracking?

Remove the file from the git repository. Add the file you want to ignore to the git ignore file. If you don’t perform this step, git will track the file when you add it back to the repository. Add the file back to the project after removing the file from the repository.

Removing a File That’s in an Xcode Project from the Repository

To remove a file that’s part of an Xcode project from a git repository, you must remove the file from the project. Select the file from the project navigator on the left side of the project window and press the Delete key.

Xcode will ask you if you want to remove the reference to the file from the project or move the file to the Trash. Move the file to the Trash.

After removing the file from the project, choose Source Control > Commit to commit and remove the file from the repository.

XcodeCommitRemovingFile

Add the File back to the Project

Now that you removed the file from the repository, get the file out of the Trash and move it back to your project folder. Choose File > Add Files to ProjectName to add the file back to your Xcode project.

Learn More About Version Control

Tags:


Leave a Reply

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