I just have some problems with commiting to github. I deleted some files through website. And then I tried to commit new files from xCode. But there was some problem so I was trying various things and unfortunately clicked “Discard all changes” and that removed one new file which was not commited before. Is there any way to restore that file? I haven’t it in Time Machine. But it’s unbeliveble. I saved project many times with that file. I compiled many times, and just suddenly disappeared? Isn’t there any “trash” folder for such things or something like that?
To be clear I would like to describe scenerio more detailed:
I had *.png files (as binary data) in my xCode project. I don’t need those files anymore so I removed them locally.
In the meantime I created new files (*.cpp, *.h and other *.png). And after all I tried to commit project. But there was old files marked with “!”.
So I went to Github repository through website and removed those files by my own.
Then when I tried to commit project from xCode, the removed files was still marked with “!”. But I decide to uncheck them and commit.
But then I get error that my repository locally is out of date, but mark “M” from all files (M - means files to commit) disappeared. But on github website there was still old files.
So I tried various things, and suddenly I clicked in xCode “discard all changes” (but please notice there was no “M” mark, just “?” mark on new files), and all those new files disappeared from my project, from finder, from anywhere.
I lost whole day work. Is there any way to recovery those files? I didn’t make any backups during day. But did those files really disappear permanently? Isn’t there any “trash” or “temp” folder for such files?
I tried to checkout repository from commit history, but it doesn’t help. The file is still in red colour in the browser, and doesn’t exist anywhere on the drive.
A proper git implementation would require you either to supply an argument to delete new files (e.g.
git reset --hard), or would give you a popup…
Have a look, if the file still exists on the disk (could be, that “Ignore all changes” reset your project, but left you the files. in this case you can simply add it to the project again.)
That’s what all git tools do, that I have used so far.
That’s the point: files don’t exist on the drive anymore, or I just can’t find them.
But it’s ubelieveble that it removed files permanently. Files which was saved, built and compiled. And they just disappeared because of discard repository changes.
Last straw: check the systems Trash, or - if you have - TimeMachine…
Sorry for losing your files, that’s why I don’t trust any GUI tool for version management…
I’ve managed to recover files lost through git by following the steps on this website a few times before: