lakshmen
lakshmen

Reputation: 29104

Issues on adding new files through git in Xcode

I added two new files to my project and added them to my github using the command

git add MyProject/File1.m
git add MyProject/File1.h

I committed the changes and push my changes to my branch.

git commit -m "added two new files"
git push origin newbranch

I ensured I didn't commit the userstate file.

When I git stash, it returns to the commited state, which is added two new files, but my files are missing in my Xcode. But when I check my folder in Finder, I am able to find them. How do I avoid this?

I would like to see my files in the Project Navigator in Xcode. It seems i need to add those files from the Finder every time. It is very troublesome.

Need some suggestion and guidance. Would Really Appreciate it...

Upvotes: 2

Views: 2971

Answers (2)

herzbube
herzbube

Reputation: 13398

The Xcode project must also be under version control, specifically the file project.pbxproj. After you have added a new file to Xcode, you then also need to commit the change to the project file.

Since git stash reverts your Xcode project to the state without the files, I guess that you did add the files to Xcode, but then forgot to commit the change to the Xcode project.

# You already had these:
git add MyProject/File1.m
git add MyProject/File1.h

# Now you also need to do this:
git add MyProject/MyProject.xcodeproj/project.pbxproj

Upvotes: 2

NSCry
NSCry

Reputation: 1652

I think your file is not added the entry of it's reference in project file of XCode.

Solution : Just add missing files using xcode and again commit & push the code into github.

Upvotes: 3

Related Questions