将当前代码推送到现有的GitHub存储库

Jon*_*ood 8 github repository visual-studio

我有几种Visual Studio解决方案,既有本地存储库又有GitHub上的解决方案。我已经进行了许多更改并将这些更改成功推送到GitHub。

但是现在Visual Studio忘记了我的本地存储库之一与GitHub存储库相关联,我似乎无法弄清楚如何重新连接它。实际上,它不再在我的GitHub存储库列表中列出该存储库。

在下图中,您可以看到我有一个名为Toxic的本地存储库,但是该存储库未出现在GitHub存储库列表中。如果我尝试将Toxic项目发布到GitHub,它只是告诉我该存储库已经存在。

在此处输入图片说明

我如何才能将所有现有的Github存储库显示在上面显示的顶部,以便我进行最新更改?

Von*_*onC 5

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
Run Code Online (Sandbox Code Playgroud)

(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)


Jon*_*ood 3

除非我遗漏了某些内容,否则唯一的选择似乎是在本地克隆 GitHub 存储库,将修改后的文件复制到新创建的存储库上,然后签入我的更改。

当然,自上次签入 GitHub 以来我丢失了所有评论和迭代。必须注意不要删除.git文件夹,并复制所有更改的文件并删除任何已删除的文件。似乎应该有一种更简单的方法,但这确实成功了。