5

So I added a bunch of images to my project that has git enabled. I then renamed all the images in Xcode. Now whenever I select commit, these files with the old file name pop up with a question mark. The question mark indicates they are not under source control, I believe, which is fine. They should not be. So how can I get them out of the list? How can I avoid this from happening in the future, other than renaming outside of the project before importing?

Note: I did not check them in or commit them before renaming. At least I don't think I committed them. They are not in the remote, nor do I want them to be.

Victor Engel
  • 2,037
  • 2
  • 25
  • 46
  • It's unclear from your question, but did you check them in previously with the old names? Assuming I've understood the current state of your local repo, you need to `git rm` the old file names and commit the deletions. – cjc343 May 22 '13 at 22:18
  • Could you add the output of `git status`? – cjc343 May 22 '13 at 22:20
  • I have not checked anything in. I don't believe I've committed the original names, nor do I have any need for any history with the original names. There are a bunch of files, so if there's something I can do in batch or with a single command, that would be preferred. – Victor Engel May 22 '13 at 22:21
  • The git status produces a list of all the files I want removed with # at the start of each line. There are no uncommitted files. Then "nothing added to commit but untracked files present (use "git add" to track)" – Victor Engel May 22 '13 at 22:26
  • So you just don't want these files to be managed by git, and you've never made them known to git. is this correct? If so, is there some reason why just adding these file names to your .gitignore will not work? – Ram Rajamony May 22 '13 at 22:29
  • I don't want to add them to gitignore. I want git to not know anything about them at all, as if they did not exist. It seems like this link may have the answer I need: http://stackoverflow.com/questions/61212/removing-untracked-files-from-your-git-working-copy – Victor Engel May 22 '13 at 22:30
  • I'm going to delete the question in a few minutes since it's apparently a duplicate of the one I just linked to. Not sure why it didn't turn up in the searches I performed. In any case, the git clean command is what I needed. – Victor Engel May 22 '13 at 22:34
  • Well, a `git clean` will remove them from your working directory. Is that really what you want? Or do you just want to not have git track those files? If its the former, then by all means git clean them. – Ram Rajamony May 22 '13 at 22:36
  • There are no files to remove. They do not exist (because I renamed them). There is no reason to track the nonexistent files. – Victor Engel May 22 '13 at 23:02

1 Answers1

3

Untracked files can be removed with git clean. Use git clean -n to preview which files will be removed and git clean -f to remove them.

Matt Jennings
  • 1,148
  • 6
  • 11