0

I have an old project that uses GitHub as the git repository.

I've just made some changes to that project and now I need to update the repository.

But, after buying a new computer earlier this year, Visual Studio no longer knows about any connection to that repository.

So how can I fix this without losing any of the changes I just made? My two primary options given are Create Git Repository and Clone Repository. I don't think I want either of those.

2
  • Does the source folder still contain the hidden .git folder? It looks like VS is not correctly recognizing your source folder as git repository. Commented Oct 16, 2021 at 18:51
  • @PMF: No, I don't see that folder. It's been a long time since I worked on this project so I'm not sure why it doesn't have that folder. But the project is definitely on GitHub. Commented Oct 16, 2021 at 18:55

1 Answer 1

2

Apparently, the hidden .git folder is missing in the project, which identifies a folder on the disk as git repository. Without this folder, no git commands will be available (whether from the command line or any GUI tool).

I suggest the following steps to resync the project to github:

  • Check out the project from github to a new folder
  • Set the checkout folder to the branch where the project was when the .git folder was lost (since it's an old project, you can probably take master)
  • Copy the contents of the existing source folder into the checkout folder. Make sure not to copy any hidden .git folders if there are still broken leftovers.
  • Verify and commit the diff.
Sign up to request clarification or add additional context in comments.

6 Comments

I can't believe any of this nonsense is necessary. GitHub is very powerful. Why there are no apparent commands to resync is beyond me.
So some of your instructions were difficult to follow. So I checked out the project from GitHub, and then I copied the .git folder to my new folder. It does pickup my new changes but it also shows other changes I made in the past. Perhaps I forgot to check them in. Trying to validate.
Git is a distributed version control system. Every working copy contains the full information of the whole repo (including its full history). This information is stored in the .git folder. The repository on github is nothing more than an identical copy of that folder. If the working copy looses the information that it is a working copy, this information needs to be restored. You now copied the information the other way round, that is fine of course.
For stuff to appear in github, you not only need to commit them but you also have to push those commits. I would not be surprised if you committed your changes but forgot to commit them. As PMF has said, git is a distributed sysem. My guess is that you are used to a non-distributed system and expecting git to behave like one. It is not. github won't magically behave the way you seem to expect because that is not the way git works.
@johnfo: This isn't about not knowing how to use git in Visual Studio. I've been using it for years. How do you think I built the repository on GitHub in the first place? My issue is how difficult to resync my copy of the repository with the repository. I think it could be much simpler.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.