开发者

Xcode 4 Git—"This file does not exist at the requested revision"

I have a local git repository that I set up with a project in Xcode 4. The repository shows up fine in the Organizer and I can see commit histories and Source Control icons in the File Navigator. Commits work fine as well. However, when I use the version editor, I get the error "This file does not exist at the requested revision" 开发者_StackOverflow中文版whenever I try to see any previous revision. I can't find any information on this error and have no idea how to fix. git log shows four recent commits (I know there are more, but I don't know if this is a restriction of the command or if something's disappearing). Any ideas?


I just ran into this same problem. I think (in my case anyway) that it was related to the fact that I had move the project directory outside of xcode. I believe xcode had cached some index files off in ~/Library somewhere. They seem to have gotten tangled up by the move.

The fix (for me) was to open xcode, open the organizer->projects pane and find the project in question. Delete the derived data (there is a button in the upper right pane for this).

After this, everything seemed fine.


This helped for me:

  1. Go to XCode -> Organizer -> Repositories
  2. Remove all repositories, with the name written in red (i.e. File not found)
  3. Tap the "+" button in the lower left -> "Add Repository..."
  4. Enter the requested information: Path = file://....<full path, which contains the .git directory>. Make sure to have Type set to "Git", Xcode changed it to "Subversion", ignore the message "Authentication required"
  5. Done


I encountered this when I changed case in a class name. Git had a lower case letter where I wanted upper case. I tried many of the things above shy of completely rebuilding the repository. I finally simply removed the class from the project, changed the name slightly then re-added it.


I'm guessing this is one of these problems that could be caused by multiple issues. This is mine and how I solved it.

My project had some file system name changes in progress. Namely, moving from all lower caps to Pascal casing. This got backed out at some point during my coding cycle. When I checked in, the file system was:

mydirectoryname

All the files under mydirectoryname were no longer managed by git under Xcode. When viewing under the Version Editor, I ended up with the "This file does not exist at the requested version" error message.

However, if I selected one of the files and clicked on the File Inspector (available in the Utilities pane), I noticed the full file path was listed as:

MyRootPath/MyDirectoryName/TheCodeFile.h

I closed Xcode, opened the .pbxproj file in an editor, fixed the path, and reopened the project. Git integration was working once again.


It turned out, in my case, that this problem had something to do with the fact that I renamed a lot of files in my repository from "CamelCase" to "lowercase", including my project file and folder. This must have been improperly tracked somewhere somehow.

OS X uses a case-insensitive filesystem by default, whereas git is internally case-sensitive, and I believe the problem had something to do with this.

These are the steps I used to fix this. If you believe your problem may be due to changing the case of filenames, this may help you too.

  1. Go to the root of your repository, and remove everything from it except for the .git folder using the "ls -la" (to see all the hidden files too) and "rm"/"rm -rf" commands.
  2. Do a "git reset --hard" to get all your files back. You may now see that the case of your filenames have changed. In my case, in the root of my working copy, "myapp.xcodeproj" and "myapp" (folder containing all the code files) had changed to "MyApp.xcodeproj" and "MyApp" (folder). I thought I had changed it to lowercase, but apparently, this hadn't been tracked properly by git.
  3. Now, rename your files to something unrelated. For instance, I renamed "MyApp.xcodeproj" to "foo.xcodeproj" and "MyApp" to "foo".
  4. Then do "git add --all"
  5. Now, rename your files to what you want. I renamed "foo.xcodeproj" to "myapp.xcodeproj" and "foo" to "myapp", which is how I wanted it to begin with (and what I thought I had already done).
  6. Do another "git add --all".
  7. Commit.

Now your life should be better and Xcode should behave well, because git is now seeing the exact same files (with the exact same case) as the Xcode project does.


My problem and solution were simple:

  • I had created a folder, myProj
  • I created an Xcode project MyProj inside this folder
  • This gave me a structure that looked like myProj/MyProj/MyProj/
  • I didn't like that extra folder level, so I moved the inner MyProj out under myProj
  • Xcode repository tracking got goofed up

The solution:

  • Open the Organizer to Repositories, and delete the upper case "MyProj" repository, which was highlighted in red. Xcode had detected the new repository location at "myProj" and resumed tracking things normally.


I came across the same error using Xcode 4.2 in a relatively new project earlier today.

I initially worked around the problem by cloning the repo into a sibling directory. In Terminal:

> cd /path/to/XCodeProject
> mkdir ../Clone
> cd ../Clone
> git clone ../XCodeProject/.git .

However, when I removed the original project and renamed the new directory to the same name, the problem reappeared.

In the end, the workaround was simply to locate my .xcodeproj and .git files and give the parent directory a different name.


I was having this happen for one particular file in a Project. All of the rest were working fine. This file never worked correctly from the time I added it, always giving the "file does not exist at the requested version" error when taking any action, including, most annoyingly, saving it! I tried removing it from the repository and re-adding it. Same. What finally worked was doing a "git add" and a "git commit" from the command line. Go to the root directory of the repository (the directory that contains the .git folder), run "git add " (even though it looks like it should already be there!) and then "git commit". This fixed it for me and the file is now happy inside Xcode.


As I know, it is due to a conflict that Xcode 4.3 currently do not handle correctly. I also had similar problem with a badly synchronized .DS_Store. I manually removed it and was stuck in a similar case.

I then had to manually solve the problem using the command line:

  • open the terminal
  • cd to the local git repository
  • cd .git/
  • mv MERGE_HEAD MERGE_HEAD_OLD // or just delete it

If you were stuck with pull, commit and push, through Xcode you should be able to call them again. Moreover, as both sides should then be correctly synchronized, your error "This file does not exist at the requested revision" will be gone as well. Please comment if this worked for you.


Had the same problem.
Solved by selecting the project in "Projects" page of Organizer and deleting both "Derived Data" and "Snapshots" data by pressing "Delete..." buttons for these fields.
After this, new snapshot can be successfully created and exported if necessary.


This is an ancient thread, but since a proper answer was never found, I will throw in my 2 cents.

One cause for this error can come from untracked files, specifically from a submodule or files that are not present in the current branch but where in a previous one.

For example, when you switch to a branch with a submodule and update such submodule, it will sync those files to your repository. When you later switch to a branch that does not have such submodule, it won't add or delete them automatically, but git will realize that something is not tracked in the branch. XCode detects this too whenever you switch to any of the Version Editor modes: log, blame, or comparison.

If this is the case, a git status prompt will yield the untracked files:

  On branch master
  Your branch is up-to-date with 'origin/master'.

  Untracked files:
    (use "git add <file>..." to include in what will be committed)

    yourSubmodule/

  nothing added to commit but untracked files present (use "git add" to track)

To fix this, you can simply delete the untracked files with rm, since those files do not belong to this branch and can be synced from the branch that actually points to the submodule. Note this is the case of the submodule, but if you do have new files you should add them to the repository instead, or alternatively adding them to the ignore list. After fixing the problem, git status should be clean:

  On branch master
  Your branch is up-to-date with 'origin/master'.

  nothing to commit, working directory clean

Read about submodules and issues with their usage.

Cheers!


I got same message after creating and renaming a new file. This message appeared when I selected the file in the Git commit window. Deleting and re-adding the file fixed the issue.


I had the same problem. It was because the editor mode is on "Show the Version Editor". Make sure it's on "Show the Standard Editor" or "Show the Assistant Editor". It's on the right top area of Xcode, next to "View" and "Organizer".


I had this problem - I solved it by : delete the repository in organiser

terminal prompt in project dir

ls -A - sheck for .git repo files - shouldnt be any - but if there are rm -R .git

then setup new git repo

git init git add . git commit -m "initial rev"

then when I reopen xcode - project is under git source control


Still no answer; I've had to do some major changes the project anyway so I started a new project. All is well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜