1

I have been working on a project and I wrote a lots of code on it. Now some of the recent codes are gone(which is quite lot). The codes missing were in existing files. newly created files aren't effected. only files effected that they were exist before and I wrote additional codes on it.

The thing is I can't figure out what did that?

I have git in my project but using git log -- filename doesn't give me any changes.

I was trying to recover a file using git diff but after that everything was fine. Can git change files like this?

I also did this solution to fix some git related error

I use vagrant with virtual box on windows. I haven't done any system restore or anything like that.

Do you have any idea what would cause this problem? How can I restore the code? Thanks.

Here is source tree status

enter image description here

Community
  • 1
  • 1
Erdem Ece
  • 1,755
  • 5
  • 22
  • 42
  • 1
    did you - by accident - ran `git reset --hard` ? if you have *committed* your changes (which you *should* have done), you might just have switched to a different barnch, and you might be able to switch back; try examining the repository with a graphical browser, such as `gitk` – umläute Sep 08 '15 at 13:25
  • I might have done git reset --hard but I don't remember committing recent changes. I included sourcetree status in my question. Do you think I can still bring back them? – Erdem Ece Sep 08 '15 at 14:43
  • 1
    the revision history in the graphical browser doesn't mean anything to *me* - it's only *you* who can tell what the given history means. apart from that: if you run `git reset --hard` you are telling git to force discard/delete any uncommitted changes: so if you haven't committed your work, that's the equivalent of saying "what I did was stupid; delete it" and there's no way to restore it. thus you ought to learn the mantra: *commit, commit, commit* – umläute Sep 08 '15 at 20:01
  • thank you for your help anyway. – Erdem Ece Sep 09 '15 at 15:31

1 Answers1

0

As stated by umläute you probably accidently ran the command git reset -hard. The only way that you could recover this is if you haven't already overwritten it, you may be able to read it off the disk.

Community
  • 1
  • 1