Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push current code to existing GitHub repository

I have several Visual Studio solutions that have both a local repository and one on GitHub. I've already made many changes and successfully pushed those changes to GitHub.

But now Visual Studio has forgotten that one of my local repositories is associated with a GitHub repository and I can't seem to figure out how to reconnect it. In fact, it no longer lists that repository in my list of GitHub repositories.

In the image below, you can see I have a local repository called Toxic, but that repository does not appear in the list of GitHub repositories. If I try publishing the Toxic project to GitHub, it just tells me the repository already exists.

enter image description here

How the heck can I get all of my existing Github repositories to show up in the top section shown above so I can push my latest changes?

like image 216
Jonathan Wood Avatar asked Jun 24 '19 18:06

Jonathan Wood


1 Answers

it appears the only option is to clone the GitHub repository locally, copy my modified files over the newly created repository, and then check in my changes.

Try fist:

  • installing Git for Windows (command-line)
  • cloning your remote repo in a new folder
  • adding your existing repository as a remote
  • fetching and see if you can cherry-pick your commits

That is:

 git clone https://github.com/<user>/<repo> newFolder
 cd newFolder
 git remote add old ../path/to/old/local/repo
 git fetch old
 git log old/master
 git cherry-pick old-sha1..old/master

(with old-sha1 being the first commit you want back)

Then add the newFolder in your Visual Studio workspace, and see if everything works (do a modification, add, commit and push)

like image 84
VonC Avatar answered Sep 27 '22 18:09

VonC