GIT with Visual Studio - Can't pull, please help

I have some basic version control set up using Visual Studio so that I can work on my game on two different computers.
It has been working; I have been able to make commits and then push and pull them to copy over the changes made on another device.

But I ran into some sort of error last night when I was trying to pull the latest changes to my laptop. I don’t have any details about the error; it just says that the pull failed. Here’s the last bit of the log:

It looks like I got everything, or at least a good chunk of it, but Visual Studio thinks I still didn’t get the pull. It still says there is one incoming. But now if I try to pull it again, it stops and gives me an error, saying that I need to resolve the changes I have made. It lists everything I got from the last pull as a change.
So I tried to revert all of that back to where it was; fine by me I can just pull it again.
I hit the little rollback arrow at the top of the list of changes, it refreshed the list, but everything is still there (or at least the stuff near the top; I have no idea if some files were removed.) And now I cannot find any option to revert to the old changes, neither can I pull the changes that I should have.

I’m stuck.

What does it print if you try to do “git pull” from the command line?

I can’t find a command line in Visual Studio, and if I type that into Windows’ command prompt I just get “git is not recognized as a command.”

Well, it means it is not installed on your system then or not in your path. Hence it is not recognized.

What changes does it think you’ve made?

In a worst case scenario you can make a fresh clone of the repository.

Right; I’m just using the functionality within Visual Studio. Whatever it installed is what I’m using.

Basically the very same changes I’m trying to pull. It brought in a bunch of files for the pull, said there was an error, and to some degree didn’t finish. Maybe the only problem is that the system doesn’t think it got the pull, but I actually have everything. Maybe there are some files and changes I didn’t get. The list of changes is too long for me to be able to tell.

I don’t know how to do that. This is the only time I’ve ever used any of this git stuff (and every single tutorial ever about version is written by someone who expects their audience to already understand how all this stuff works like they’ve been using it at work every day for the last five years.)

I believe you’ll need to learn how to use git, at least basics. And there isn’t really any way around it.

That’s what they’re doing. This doesn’t magically appear in someone’s head fully formed. They do stuff with it and learn bit by bit.

And it’s a major spanner in the works when something like this happens.

Errors such as “pull operation failed” without further info are near useless. I love Git, but I’m one of the first to say that the UX is terrible.

Where and how did you set up your repository?

1 Like

Phone autocorrection glitch?

git basics can be taught by git-tutorial which is available through command-line if git is installed.
github, I believe, had some tutorial as well. Somewhere.

This isn’t the 90s. “Beginner” and “command line” haven’t gone together for at least two decades.

1 Like

I honestly do not care if it is 90s or not. And command line is not something unimaginably difficult.

Command line tool will likely spew relevant information for him if he fires command. That’s the reason why I suggest to run it.

You’re free to recommend him an alternative approach.

Most likely scenario is that you have a conflict. Meaning there are local files that were altered, or you’ve changed the same file from both computers at the same time, and now git can’t decide what you want to do with it.

Normally with this kind of situation, git will stay in “unfinished pull state” and will ask you to resolve the changes, yourself. That would mean selecting either “their” vs “our” version for a file, or manually going through the changes.

Normally the contents of “conflicted file” will have something like this inside:

That will be LITERALLY stored int text form inside the file as:

<<<<<<< HEAD
green
=======
white
>>>>>>> his-branch

The thing is, when I deal with sort of thing by hand, I use command line interface, and I have no idea how it is done with whatever GUI visual studio extension you’re using. That’s one of the reasons why I suggested cli - because regardless of GUI extension you’re using, CLI interface is always the same and doesn’t change.

If you want to learn git cli interface, you’d need to either install it system-wide or play with linux virtual machine. If git is available on system, you can type “git” within the terminal, and git-tutorial should help you.

You could also try something like this:
https://learngitbranching.js.org/
But I’m not sure if it is any good.

I should follow up on this. How is it showing you this? A screenshot may help. Chances are that one or more files needs you to take action.

Haha, yep.

Yeah, a command line is easy enough to learn to use. The point is that at this stage it’s adding two additional things (general command line usage and Git CLI) between the user and starting to do what they’re doing.

With Microsoft Azure. I honestly can’t remember much beyond that; I recall there was a good dozen or more subsets of Azure all catering to different things with no clear guide on what did what. Azure Repos I think? It was something suggested by someone else on this forum.
And I’m using Visual Studio to run all the commands and stuff because it’s already right here and available since I’m using it with Unity.

YES. THANK YOU. This is a bit off-subject here, but it infuriates me how programming and related subjects are taught, because the people doing so just seem to think that beginners should already understand the most advanced concepts. I can STILL go the store and buy a brand new this-year-edition of a book on “beginning” programming and find their Hello World example is outputting to the console.
Now, I know what the command prompt is because I actually am old enough that I used to use DOS. But who in their right mind is going to expect someone in high school to have any familiarity with that? At the very least it will instantly put people off from programming because it is not giving them a relatable example. The “hello World” example should make a generic windows dialogue box. Yes it’s a more complicated program that way, but it would be something relatable that a beginner would actually recognize, plus it gives an immediate springboard into teaching interesting stuff. Show them what things they could tweak to make the window bigger, or to make a new button.
I love the idea of teaching programming with video games because it gives students something they can recognize and relate to right away. Give them a working shell of game to start with, and then show them things they can tweak, or have clearly missing elements of a game that serve as a way to teach the fundamentals like variables as they build something they can identify.
All those lessons that try to teach students to make a spreadsheet in a command console can go to hell, that BS is the whole reason why I wasted twenty years of my life thinking I couldn’t program.

That sounds somewhat reasonable, but every time I have had any changes in my system I had to resolve them before I could fetch any incoming commits. I mean, that’s literally the problem I’m facing right now; I can’t actually pull the last commit because the system sees all these files I’ve changed (they were brought in from the pull that failed) and it won’t let me pull the “new” one in until these conflicts are resolved.

I certainly see an advantage with that, and that is more my style. But I do not yet understand this stuff well enough to switch to having such direct control over everything.

As someone who learned programming that way… the point isn’t that I was expected to already know how a CLI works. The point was that the books, and later the teachers, wanted me to learn how it worked. Sticking to the CLI is also a great way to make sure that students stick to and learn the fundamentals before they move on. The time they spend tweaking that GUI button is time they were distracted from what algorithms are or how functions work. I’ve taught people with both methods, and I’m pretty confident that going “slowly” gets faster results. :slight_smile:

Nonetheless, while it’s a completely reasonable approach for those already in the know, the whole “use the CLI” shtick definitely contributes to the perception of Git being super complicated. And most GUI clients unfortunately just wrap the CLI commands and outputs without actually making the workflows any nicer.

It’s a great tool and all that, but the UX could definitely use some love.

Anyway…

Right, in that case you can log into your Azure DevOps, go to the project repo, and it’ll give you a URL to clone. That’ll get you a fresh copy of the project with whatever was pushed most recently, without any other stuff from any of the workstations. That’s if you want to take the “nuclear option” and just start again with a fresh copy.

However, chances are you’re going to run into something similar again. So it’s best if you figure out what happened and the right button to fix it. It usually makes perfect sense once you know what’s happened. In that regard, screenies might help us help you. :slight_smile:

1 Like

Meant to post this on the first post…

The changes are basically the entire commit I already tried to pull.
I don’t know if there are some changes that are missing from that list or not; there is no reasonable way for me to check all 552 files.

EDIT: Sorry, wrong pic. It’s late at night and I’m jumping between my two devices.

Because that’s literally the simplest thing you can teach (that is universally useful) without touching advanced concepts first.

GUI requires a framework. Framework requires advanced concepts. Beginner does not have those concepts.

Hence, console/terminal.

The reason why I suggested CLI interface, is because talking to git through cli is akin to standard language, and talking with it through GUI is akin to dialect/pidgin. I do not know your GUI plugin/dialect, and hence I cannot help you.

Meanwhile in console interface, you can run “git status” and it will write you what is happening, what files are staged to commit, which ones are modified, and whether you’re in a middle of resolving conflict or not. Git pull would also print what’s happening and why pull has failed.

By the way, you should try cycling thorugh VS windows, because there was an “output” window which could print more information.

1 Like

That looks like the properties window for an object. What we’d need to see is the file list associated with the current state of Git. It’ll probably show in the same window or panel you use to commit / push / pull.

In cli interface. To check changed files:

“git diff --stat”

To see exact changes:
“git diff”

To checkout a file
“git checkout filename”

To reset and get rid of the changes completely (destructive)
“git reset --hard”

To see what’s happening:
“git status”

Normal situation would be to check what’s going on with “git status”, with “git diff --stat” see files that changed, run “git diff” and scroll through to see what’s happening.

Your files are all marked with “A” meaning they were all added locally and haven’t been commited first. Or at least the system thinks this way.

From thsi point you could attempt to make them a commit and hope the git will be able to merge changes during pull, but if that’s busted commit, that’ll only result in a conflict instead.
You can also try to wipe them out with hard reset if you’re sure there’s nothing taht you need there. The system will also complain if there’s a stray untracked file at the same path as pulled data.

Aha, I see you fixed the image.

The problem is described at the top: “Cannot pull because there are uncommitted changes.” This means that you’ve either added or changed files and not committed them. That’s not always a problem. However…

It is most definitely a problem if the local changes and the changes you’re pulling include some of the same files. Git will not overwrite local stuff with remote remote because you could easily lose data that way, so it makes you fix it first. The solution is in the next sentence: “Commit, stash or undo your changes…”. The Output Window it refers to will show you a list of the specific files.

So you just* need to:

  1. Do another commit on that computer and make sure it includes all of the changes you want to keep.
  2. If there are changes you don’t want to keep then revert those files so that Git knows they can be overwritten.
  3. Repeat the pull operation.
  4. Do a push straight away, so that the local changes from step 1 are already up on the server.

If the list of locally changed files is a huge number of files you didn’t actually change then usually that means that a directory has been renamed. Git will initially see that as all of the files at the old path being deleted, and then being re-added at the new path. Have you re-named anything lately?

  • You probably see a list of steps and groan on the inside. With a bit of practice this’ll be second nature, though. And it’s a fraction of the effort of keeping stuff in sync manually!