In Xcode, I mistakenly clicked the Convert to use Test Plans
button, and Git showed that the .xcscheme
file had been changed:
On branch TestBranch
Untracked files:
(use "git add <file>..." to include in what will be committed)
MyProject.xcodeproj/xcshareddata/xcschemes/MyProject-UI-Tests.xcscheme
nothing added to commit but untracked files present (use "git add" to track)
I wanted to roll back the change, but the file is untracked, so there's nothing to roll back to.
I tried resetting the HEAD back to the last good commit, but this change stays (which is understandable, since it's not being tracked by Git).
I had a backup copy of the project from the day before, so I was able to restore the .xcscheme
file manually, which restored Xcode's state back to the way it was prior to clicking the Convert to use Test Plans
button, so that's good.
However, now that Git is aware that this file has changed, it keeps warning me, even after I restored it to the original state.
The easy fix would be to add the .xcscheme
name to the .gitignore
file. However, I don't want Git to ignore the file in the future, in case this happens again for some reason (ie, I like that Git told me which file had been changed, so I knew which one to rollback manually to fix it).
The next best easy fix would be to add the .xcscheme
file to Git so it is being tracked, but my teammates asked me not to include this file because they don't want it being tracked.
So, the question is this: Is it possible to make Git forget the change to .xcscheme
up to this point, but still alert me if it changes in the future?
CodePudding user response:
However, now that Git is aware that this file has changed, it keeps warning me, even after I restored it to the original state.
Git should not "warn you" (about an untracked file) any more after restore than before.
Showing MyProject-UI-Tests.xcscheme
in the untracked section of git status
does not mean it has changed, only that is is untracked.
Git cannot forget changes of what it does not track.
Only an external process comparing that file to a pristine copy (a backup you know has the right content) could alert you of any change.
The OP James Toomey confirms in the comments:
I was wrong that this file had been there all along.
There are multiple
.xcscheme
files, but the UI-Tests one only appeared once I clicked that button.
So, the reason the file appeared in Git's "untracked files
" section is because this is a new file that had never been there before, so Git is basically saying, "what to do with this new file, do you want to
a) start tracking it (withgit add
), or
b) ignore it (by adding it to ".gitignore
")?