mslee017
mslee017

Reputation: 41

Local Files Disappearing After Push to Github

I'm having a rather annoying issue that is likely a simple problem to fix, though I cannot find any solution on google to it.

I'm currently working on an assignment that requires me to switch between branches that are "checkpoint" based work and "assignment" based. Basically what's happening is every time I push something to Github, the local files in the folder I'm working on seem to...disappear and I don't know why. I have to recreate the files and copy/paste code into it every time and it is driving me insane. Here is what I have been doing at the end of either completing a checkpoint or assignment;

git add .
git commit -m ""
git push origin "checkpoint name"
git checkout master

And after that's done, the files in my work folder are no longer in my local for some reason and I can't figure this out.

Upvotes: 3

Views: 5256

Answers (2)

joliejuly
joliejuly

Reputation: 2257

Decision for XCode users:

I faced the same problem: after synchronizing with GitHub all my new local files disappeared, though they were still present on GitHub. That drived me mad.

The problem was in xcodeproject/project.pbxproj file. It controls files presented in the project. More on it here: Should I git ignore xcodeproject/project.pbxproj file?

It turned out that it was in my .gitignore file!

To check this out, open Terminal and do:

cd //go to your root directory
open .gitignore_global //first, look in your global .gitignore

If you have this file, it will be opened in your text editor. Look for the line

*.pbxproj

and delete it! If you don't have .gitignore_global, then navigate in Terminal to your directory with Xcode project, and do:

open .gitignore //this will open your local .gitignore for the project

And again, find *.pbxproj line and delete it.

I wish I had this answer earlier, so I decided to add it here.

Upvotes: 0

Pradheep
Pradheep

Reputation: 3819

The problem is that the last command switches the branch to master and since the changes are not merged to master the changes are not visible in the master branch.

What is suggested is not to execute the last command git checkout master and continue working and once all the changes are done, then merge with master.

Look into the tutorial for more details https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Upvotes: 5

Related Questions