How do I clear up this git mess in VSTS?

Hi,

I'm trying to learn how to use git in VSTS (have the right structure to my project from the start). The "beginner" guides are absolutely woeful. e.g. the "beginner's" guide to VSTS, assumes you are merely new to VSTS, and know how to use git, which I don't (the same is true of many "Beginner" guides - "beginner" doesn't seem to mean what it used to :-( ). This is in Visual Studio on Windows 10 - a desktop and a laptop (so I can work on either machine once I sort out how this all works).

I seemed to be making progress, but in trying to get everything synced up on every machine I seem to now be in a Catch-22. Several times it said I couldn't do what I was trying to do because I had uncommitted changes. I hadn't actually changed anything(!), but I did as it requested (made a commit even though I hadn't changed anything). Now I have commits from both machines, and neither will progress. i.e. when I try to pull/push changes, it won't let me - this is in both directions (won't let me push the local changes, nor pull the remote ones).

So, it's saying that if I pull the commits, it will change one of my local files, which I'm ok with, but that's it. I can't see how to make it actually do that. i.e. go ahead and change that file and allow the pull to happen. How do I get out of this mess, short of starting from scratch all over again? (which I considered, but I want to learn how to fix this in case it ever happens again when I have actual changes at stake)

thanks,
Donald.

Tagged:

Best Answer

  • SmartmanAppsSmartmanApps AU ✭✭
    edited November 2018 Accepted Answer

    While I was looking at something else, I saw in a screenshot that the author had an option to include a .gitignore file. Since I wasn't sure what to put in one anyway, I went to try that (with a new project). I didn't get the same screen (he was on a Mac) but I did see an option to "create a git repository", which wasn't checked, so I checked that and voila(!), there's a gitignore file with all the stuff already in it. :-)

    So, tried a few commits back and forth, and all looks to be working ok. :-) Just need to go back and fix up the other project now.

Answers

  • JohnHairJohnHair GBMember ✭✭✭✭✭

    Hi Donald,
    If you are sure that you have checked everything in, then delete the local folder and clone it again from the server.
    Be aware in git you can commit locally, however this does NOT push it to the server until you tell it to. So check your source in VSTS to ensure you have checked in everything before deleting.

  • SmartmanAppsSmartmanApps AUMember ✭✭

    Hi John,

    Sorry it took me a while to respond, but I'm back on the case today.

    I deleted and re-cloned on both devices, and all good - both have the current version of the program. I was glad this worked, as I don't know how to make sure everything is checked in - I can see no reference to it anywhere in VS team explorer. Anyway, now that all re-cloned, let's try again (this may not be in the exact order it happened - I should've written this down as I was going so that it was in absolutely correct order of what happened)...

    Made a simple text change on my PC - working. Commit and push to VSTS - worked. Tried to fetch and pull down the change on my laptop - AGAIN it says that I can't do the pull because I have unsaved changes. I didn't change anything! All I did was clone it and run it to make sure it was working.

    Let's see what happens if I commit these alleged changes. Delete and re-clone. Try to commit changes, and it comes up with 30 merge conflicts - WTF?! I haven't changed a thing since I cloned it. There shouldn't be ANY merge conflicts. Argh. This can't be right. Delete and re-clone again. Try something else.
    

    Tried to pull (without fetch first). Again tells me has unsaved changes. Try to commit, and NOW it tells me it can't save the changes because "confused by unstable object source data". Now I can't get it to work at all on my laptop - I get this error even after a delete and re-clone!

    Also, at some point (don't remember which attempt) I had that message I mentioned before, where it warns me it will overwrite some local files if I do the pull, but doesn't give me any option to say "ok" and go ahead and actually do it. They are...

    ...../v15/Server/sqlite3/storage.ide-shm
    ...../v15/Server/sqlite3/storage.ide-wal
    

    So, initially deleting and re-cloning got me working on both devices... but you wouldn't want to have to do that every time you make a change on one of them. Now even re-cloning can't get it working on the laptop!

    Help?!

    @JohnHair said:

    Hi Donald,
    If you are sure that you have checked everything in, then delete the local folder and clone it again from the server.
    Be aware in git you can commit locally, however this does NOT push it to the server until you tell it to. So check your source in VSTS to ensure you have checked in everything before deleting.

  • JohnHairJohnHair GBMember ✭✭✭✭✭
    Just a heads up, Commit only commits locally. Git is a distributed version control system. So now you need to Sync. Next time you want to commit select the Commit & Sync option instead.
  • SmartmanAppsSmartmanApps AUMember ✭✭

    Yes, I did the sync - sorry if I left out that detail, but as I said, VSTS has the updated code. It's only when I try to download the latest commit to my laptop (having made the change on the PC and synced it to VSTS) that I run into trouble, and that's part of the whole point to be using it to begin with! Work on the code from multiple devices. I just can't for the life of me get the laptop to just pull the commit from VSTS - as I said it tells me I have uncommitted changes (having only just deleted and re-cloned it!), that it would overwrite files (which I want it to, but there's no option to say "Ok, overwrite the files"), that there are merge conflicts, and now this "unstable object source" business, and I never changed a thing after re-cloning it! Just opened it up and built it to make sure it was working (which it was... until I then try to get the commit I made on the PC).

    @JohnHair said:
    Just a heads up, Commit only commits locally. Git is a distributed version control system. So now you need to Sync. Next time you want to commit select the Commit & Sync option instead.

  • JohnHairJohnHair GBMember ✭✭✭✭✭
    if you try to commit on the laptop it will show you what it thinks has changed, what does it list?
  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    I would use right click on your project where it says you have uncommitted changes and then "Version Control > Review and Commit" so that you see what has changed. And maybe you'll discover that these are intermediate compilation files or binaries which should not be version controlled anyway. If that's the case, adding (or extending) the .gitignore file at root will save you future headache.

  • SmartmanAppsSmartmanApps AUMember ✭✭

    Thank you both for your responses. :-)

    So, after it was all in a complete mess last time, when I have started everything up again today I've found I'm back to square 1 - which is an improvement on where I was last time, but not sure how I got there. Anyway...

    @XavierPerseguers when I right-click on the message saying there are uncommitted changes, all I get is the option to copy the message text. As I said, I'm a newbie to this, so I don't know anything about .gitignore file (I don't see one there, though I do see a .git folder), though I could do some reading up on that (I am presuming, when you say "at the root", that you mean the top-level folder where the .sln file is found? I can also see .git and .vs folders there).

    @JohnHair Having now managed to get back to square 1, this is the original message (which took me aback, having only changed a character in the text in the label) - this was a (supposed to be) simple project to test out using the hosted Mac agent on VSTS (but also using it to test out using VSTS git capabilities across devices)...

    The pull would overwrite your local changes to the following 31 files:
    .vs/HostedMac/DesignTimeBuild/.dtbcache
    .vs/HostedMac/v15/.suo
    .vs/HostedMac/v15/Server/sqlite3/storage.ide-shm
    .vs/HostedMac/v15/Server/sqlite3/storage.ide-wal
    .vs/slnx.sqlite
    HostedMac/HostedMac.Android/obj/Debug/MonoAndroid71/HostedMac.Android.csprojAssemblyReference.cache
    HostedMac/HostedMac.UWP/bin/x86/Debug/App.xbf
    HostedMac/HostedMac.UWP/bin/x86/Debug/AppX/App.xbf
    HostedMac/HostedMac.UWP/bin/x86/Debug/AppX/HostedMac.dll
    HostedMac/HostedMac.UWP/bin/x86/Debug/AppX/MainPage.xbf
    HostedMac/HostedMac.UWP/bin/x86/Debug/AppX/entrypoint/HostedMac.UWP.exe
    HostedMac/HostedMac.UWP/bin/x86/Debug/AppX/vs.appxrecipe
    HostedMac/HostedMac.UWP/bin/x86/Debug/HostedMac.UWP.exe
    HostedMac/HostedMac.UWP/bin/x86/Debug/HostedMac.UWP.pdb
    HostedMac/HostedMac.UWP/bin/x86/Debug/HostedMac.dll
    HostedMac/HostedMac.UWP/bin/x86/Debug/HostedMac.pdb
    HostedMac/HostedMac.UWP/bin/x86/Debug/MainPage.xbf
    HostedMac/HostedMac.UWP/obj/x86/Debug/App.xbf
    HostedMac/HostedMac.UWP/obj/x86/Debug/HostedMac.UWP.csprojAssemblyReference.cache
    HostedMac/HostedMac.UWP/obj/x86/Debug/HostedMac.UWP.exe
    HostedMac/HostedMac.UWP/obj/x86/Debug/HostedMac.UWP.pdb
    HostedMac/HostedMac.UWP/obj/x86/Debug/MainPage.xbf
    HostedMac/HostedMac.UWP/obj/x86/Debug/ResourceHandlingTask.state
    HostedMac/HostedMac.UWP/obj/x86/Debug/intermediatexaml/HostedMac.UWP.exe
    HostedMac/HostedMac.UWP/obj/x86/Debug/intermediatexaml/HostedMac.UWP.pdb
    HostedMac/HostedMac.iOS/obj/iPhone/Debug/HostedMac.iOS.csproj.CoreCompileInputs.cache
    HostedMac/HostedMac.iOS/obj/iPhone/Debug/HostedMac.iOS.csprojAssemblyReference.cache
    HostedMac/HostedMac/bin/Debug/netstandard2.0/HostedMac.dll
    HostedMac/HostedMac/bin/Debug/netstandard2.0/HostedMac.pdb
    HostedMac/HostedMac/obj/Debug/netstandard2.0/HostedMac.dll
    HostedMac/HostedMac/obj/Debug/netstandard2.0/HostedMac.pdb

    As mentioned previously, when this came up before, I went through all these merge conflicts and told them to stick with the hosted VSTS version, but then got in a further mess (as previously written about). Hopefully we can resolve this at this point instead (no fun resolving 31 merge conflicts which shouldn't even really be there to begin with since I only changed 1 text character!).

  • SmartmanAppsSmartmanApps AUMember ✭✭
    edited November 2018 Accepted Answer

    While I was looking at something else, I saw in a screenshot that the author had an option to include a .gitignore file. Since I wasn't sure what to put in one anyway, I went to try that (with a new project). I didn't get the same screen (he was on a Mac) but I did see an option to "create a git repository", which wasn't checked, so I checked that and voila(!), there's a gitignore file with all the stuff already in it. :-)

    So, tried a few commits back and forth, and all looks to be working ok. :-) Just need to go back and fix up the other project now.

Sign In or Register to comment.