Forum Visual Studio

Git Update overwrote all my code and deleted new files

I decided to do an Update of my project, in Xamarin Studio, before committing four days of work to a remote GIT repository.

In other IDEs I've used in the past, such as Eclipse with CVS, an update would bring down modified files and tell me about any conflicts with stuff I've changed, allowing me to merge any changes before then doing a commit.

Unfortunately an Update with Xamarin Studio completely overwrote everything in my project, with the codebase from four days ago. Not only that but it deleted every new file I'd created. So I've also lost new screens, new controllers, interfaces, etc, etc.

Does anyone know the logic behind this, was it a bug or is that the expected behaviour?

And does anyone know what happened to my deleted files, do they exist somewhere?

I've downloaded a file recovery program that's so far reporting almost 3000 unnamed .cs files as recoverable, it's gonna be an absolute nightmare opening them all and narrowing down the files.

In hindsight I should have committed the files locally before doing an update from remote, so at least I had a local backup, but not for a second did I believe something as simple as an update was gonna overwrite everything and delete new files, at least without checking with me first.

Thanks in advance.



  • DannyCDannyC US ✭✭✭✭

    Not sure this is an expected behavior but check your local stash. Had a similar problem once and all my changes were in the stash.

  • Thanks for your suggestion DannyC, unfortunately there was nothing in the stash.

    I've managed to redo most of what I lost and this time I committed everything, before doing an update, and it was fine. I then pushed up my changes.

    So it looks like doing a Update discards any untracked changes or files, I've learn't more about how Git works since and can kind of understand why it does that.

    It was a harsh lesson, but maybe Xamarin Studio should warn the user about doing an update if it knows there are untracked files or changes.

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    Hey DanFordham,

    Go to Options -> Version Control -> Git. Do you have automatically stash/unstash local changes ticked? Otherwise, it's going to make you lose the changes.

    We should throw a warning though, you are right.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Very sorry about this, data loss bugs are very serious and we should certainly prevent these kinds of things happening accidentally. @mungureanu, could you file a bug and track this as a high priority issue?

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    Filed a bug and will take care of this today.

  • Thanks guys, much appreciated.

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai
    edited August 2013

    But can you verify if you have stash/unstash ticked or not? :D

    Edit: I'm trying to find out if stash failed or you just didn't have the option on.

  • Hi there,

    That option is set to on.

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    And you lost the changes? I'm thinking about some issue from the past. Does the project include submodules?

  • I'm not sure what you mean by submodules.

    My solution has 5 projects, one of them is Core (that doesn't build) and another iOS.

    The iOS project was the one I was working on, and this has a few links to code and resources in Core.

    I lost new files in both Core and iOS when doing the update.

    The Git repository covers the entire solution.

  • algranoferalgranofer DEMember

    I can confirm that this problem still happens on version 4.2.2, I also lost all my new files during the update. Both the "Automatically stash/unstash local changes" and "Use the Rebase option for merging" options are checked in the Version Contro, Git section.

    Could the latter be causing this behavior?

    I usually use the command-line to control git gave it a try since I was right there on XS.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    If you have "Automatically stash local changes" checked, you might not have lost your code, it may simply still be stashed.

    If you open a Terminal and navigate to your project directory, try the following command:

    git stash list

    That should show a list of available stashes. Most likely, it'll be the most recent stash, so you can simply use the following command to restore it:

    git stash pop

    (The stash is a stack)

    Hope that helps.

  • GregFerreriGregFerreri USMember ✭✭

    I know this is an old post, but the same thing happened to me yesterday, as I was preparing to commit some changes that I made using the built-in Version Control features of Xamarin Studio (Mac version 5.2.1 (build 1)).

    I believe that I accidentally selected "update" instead of diff, and without warning, all of my new files and changes were obliterated. There really needs to be some warning messages put in around that behavior, if that is truly the desired functionality.

  • JauchJauch PTMember

    This JUST happened to me right now. I press Update for mistake.

    The simple possibility of lost everything by the press of a buttom, WITHOUT any warning, is so absurd that I'm almost speechless.

    One day of work lost, without any way to recover.

    Thanks guys.
    You're really awesome.

    More than a year since someone pointed this "possibility".
    I don't need to say that I'll unistall Xamarim from my computer, of course.

    Cheers and good luck.

  • DamienLynchDamienLynch GBMember

    This just happened to me now as well in version 5.5

    Come on guys. Not good enough

  • mikescandymikescandy ITBeta, University ✭✭

    And... just happened here too.
    Lucky me, I had a copy somewhere else.
    This is pretty bad behaviour, really. It's not nice to delete files without warning!

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    Did anything happen to be in the logs? Any exceptions related to Version Control in the session that caused the losses? I have been unable to reproduce it on my end ever since the report came in. There is something environmental that's causing this and I don't know what.

  • DannyCTACDannyCTAC USMember

    It just happened to me to. I created a SingleViewApp on my Mac. Added it to GitHub immediately. After a lot of changes I selected Version Control / Update Solution and now all new files are gone!
    All Stash options were already set on, but no stashes in the Stash list. I am really not happy with this!

  • This is really embarassing guys. Seriously. Same issue in 5.5.3 build 6. "Version Control->Update" wiped out the files, no stash. Automatic stashing is enabled already. I even saw it say it was stashing my changes. Wiping out work right before a commit is the fastest way to lose customers. It doesn't matter what other features you have if this is how the IDE behaves. Get it fixed.

  • To the extent that it's helpful, I've done some digging: the file system reports that my files were modified by the update at 7:46PM (19:46). I'm attaching the portion of the Xamarin log from 7:45 up to 7:47. It doesn't seem to mention anything specific to the VCS, but perhaps it will still be useful. (No other logs on the system mentioned the vcs/git/pull/fetch/update etc.)

    Apologies if I sound overly frustrated in that previous post. :) I can only imagine how tricky these problems must be to diagnose. Best of luck to you!

    Log.txt 24.1K
  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    I'm looking into this. Sorry for any problems caused, but it's a really weird error and it seems to be environment specific.

  • Hi Marius - thanks for keeping an eye on this issue. If you need to produce a version of Xamarin Studio instrumented for this problem, I'd be happy to run it just in case it happens again. Often the hardest part of a bug like this is getting good information back from clients. I'm happy to help, if I can.

    Best, -J

  • ReinisLusisReinisLusis LVMember

    4 days of work gone. Will try to recover some code from .net .dll but this is very very wrong. And it happened when I was pushing changes.

  • JasonWJasonW USMember

    I just ran into this problem myself. This is no small issue. If you can't make this work without the potential for completely losing files then you need to remove the feature. Integration into version control is nice. Not losing files is better.

  • RickStrickerRickStricker USMember ✭✭

    Just did an Update Solution and lost 3 days worth of work. Ugh!

  • I have the same issue for Xamarin Studio 5.5.4(build 15). Please take a look into this bug. It should be considered like critical.

  • Let me know when it will be fixed!

  • SammDesmondSammDesmond USMember

    Just happened to me as well. Couple days worth of work lost. Simply showing a warning would be immensely helpful.

  • DavidCarawayDavidCaraway USBeta ✭✭
    edited February 2015

    For the love of God I just lost 8 days worth of work. I clicked on a single file, selected Version Control->Update and it updated my entire solution!! I expected a single file to be updated. I have stashing enabled but it doesn't show anything at all. I'm using XS 5.7.1 Mac. This is pretty ridiculous. Saying "sorry" doesn't help much.

  • I just lost 12 days of work and I have a delivery on in 2 days!! How can this even be happening? And to this many people? This should be highest priority since you use version handling for safety and backup as much as collaboration! This is NOT Acceptable!!

  • And yes I use auto-stash which worked a bunch of times before it just decided to take a vacation without notice!
    Xamarin should go out with a public warning about these things till it's solved to avoid that more people end up where we are / was...


  • DavidCarawayDavidCaraway USBeta ✭✭

    Yes, this needs to be a hotfix update sent out asap with a warning to developers in the meantime. I can't think of much that has more priority than having a bug that destroys your hard work.

  • IconiqIconiq USMember

    Hi guys ,

    This just happened to me too. I received a console message saying it stashed and unstashed, but my changes are gone. Luckily I commit every few hours, but still, no real happy I've lost my work.

    If it helps at all, I'm using a starter licence and my repository is on bitbucket, Zamarin 5.8.3

  • IconiqIconiq USMember

    Okay, I'm not sure if you guys are still looking into this but I managed to recover my files.

    I am very unfamiliar with git so there is probably an easier way to go about this.

    Following the advice here I ran these commands

    git fsck --lost-found
    ls .git/lost-found/other

    When I looked through the files in /other, only one was plain text, and I couldn't read the rest.

    However I noticed that there was a file with a hash in /lost-found/commit

    I ran git stash apply

    And that put everything back the way it should be.

    I'd like to note, that running git stash list returned no results.

    I hope this helps you analyse the issue and anyone else from loosing too much time and work.

  • MariusUngureanuMariusUngureanu ROXamarin Team Xamurai

    Hey @Iconiq, thanks for that information. This is rather a weird symptom.

    I still haven't managed to reproduce this issue, and I've been using Git in XS daily. I've tried GitHub, GitLab, BitBucket, no dice at repro-ing.

    Good news is that we're switching the backend from NGit to LibGit2Sharp, so the overall experience should be of higher quality than it is now.

    Sorry for the inconveniences caused for everyone in this thread.

  • XamGuruXamGuru AUMember ✭✭

    I lost my 2 days of uncommitted work when I ran update solution. Using bitbucket to manage my code. Can't believe it is still happening.
    Whats the best way to handle this issue from our end??
    The only quickfix I can think of is to create a copy of working folder before running Update Solution. Not sure how to merge the solutions if I happen to loose all my work again.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    @XamGuru open a Terminal window, cd into your project directory and then type:

    git stash
    git pull --rebase
    git stash pop
  • XamGuruXamGuru AUMember ✭✭
    edited May 2015

    @jstedfast thanks for the code. The work that I have lost can't be recovered but for next time I will definitely stash my changes and then pull the master.

  • AnthonyAdamskiAnthonyAdamski USMember
    edited May 2015

    Just lost a weeks worth of work! Please fix this ASAP. I'm blown away as to how this is still an issue.

  • Jayendra_KholeJayendra_Khole USMember ✭✭

    I lost my couple of days code after updating solution.
    Anybody get the solution for this issue because its very dangerous.
    Simply Xamarin yet not trust-able studio, Really disappointed with Xamarin

Sign In or Register to comment.