2

I have gotten myself into some hot water regarding source control.

I had just gotten a feature branch to work that another developer on my team had created and developed, which required adding some files. He then added some additional code to the project, and I wanted to revert to the version of the branch I had started with before I pulled his new code so that I wouldn't have to worry about merging these new files.

So, as per git's recommendation, I unstaged the changes I had made and used:

git checkout -- ScrollingTextLabels.xcodeproj/project.pbxproj

followed by:

git pull

I had assumed that the pull would replace the project.pbxproj file with the one from the origin, but instead git spat out a lot of lines beginning with "delete mode", most disconcertingly:

delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj

Every time I try to open the project on this branch, I now get the following error message from Xcode:

Project /Users/myname/Documents/Code/organization/product-ios/ScrollingTextLabels.xcodeproj cannot be opened because it is missing its project.pbxproj file.

I have been able to switch to other branches, which are still working fine, and must have their project.pbxproj file.

Also, I attempted to use git reset --hard to no avail. Should I force an overwrite (a la How do I force "git pull" to overwrite local files?)?

Should I delete the branch locally and pull from origin?

All I want is for the remote version of this branch, which is working well, to appear unchanged on my computer so that I can open it and continue working.

Community
  • 1
  • 1
eLillie
  • 653
  • 9
  • 17
  • what was the output of `git reset --hard `? – bitoiu Jun 05 '15 at 01:06
  • 1
    Are you _sure_ that the remote version of the branch has the file, and is "working well"? Judging by the `delete mode` message you got upon pulling, it seems like someone deleted it. – David Deutsch Jun 07 '15 at 16:20
  • @bitoiu `git reset --hard` outputs `HEAD is now at 011abef [commit message of the commit that I'm trying to reset to]` – eLillie Jun 08 '15 at 16:07
  • @DavidDeutsch I discussed the issue with my co-worker and you may be right. The remote has since been fixed, but I've made a mess of my local repository trying to figure this all out. So, I'm going to just rename my old repo and clone the remote. – eLillie Jun 08 '15 at 19:32

1 Answers1

1

The message

delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj

during a merge (or pull) indicates that the file was deleted in the to-be-merged branch. It does not exist anymore in the other branch, your co-worker must have deleted that file.

Deleting a branch and pulling does normally not solve anything. You already have all changes from the remote (probably in origin/branch). Either checkout a new branch from that commit, or reset to it (potentially losing all your local changes!)

Use git log origin/branch or gitk to view the changes of the branch. You can also show the log for this single file only with git log origin/branch -- ScrollingTextLabels.xcodeproj/project.pbxproj. This should tell you, what happened to the file and whether it was deleted in the branch.

knittl
  • 246,190
  • 53
  • 318
  • 364