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

标签 visual-studio github repository

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

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

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

enter image description here

我到底如何才能让我所有现有的 Github 存储库显示在上面显示的顶部,以便我可以推送我的最新更改?

最佳答案

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.



试试拳头:
  • 安装 Git for Windows (命令行)
  • 在新文件夹中克隆远程仓库
  • 将您现有的存储库添加为远程
  • 获取并查看您是否可以挑选您的提交

  • 那是:
     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
    

    ( old-sha1 是您想要返回的第一个提交)

    然后在您的 Visual Studio 工作区中添加 newFolder,并查看是否一切正常(进行修改、添加、提交和推送)

    关于visual-studio - 将当前代码推送到现有的 GitHub 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56741930/

    相关文章:

    visual-studio - Visual Studio : Add service reference to service in a different project in my solution?

    c# - 重现 "close over the variable of a foreach"陷阱

    javascript - Apache Cordova 中的 HTML 模板?

    svn - Subversion 在 '..\..\..\subversion\libsvn_wc\update_editor.c 的第 1550 行报告故障 'action == svn_wc_conflict_action_delete'

    git - 当同一分支上有新提交时,自动将本地 git 存储库与远程存储库同步

    linux - 检查本地 git repo 是否领先/落后于远程

    .net - XML xpath Visual Studio

    ubuntu - Linux 软件包存储库中的 *​​-dev 软件包实际包含什么?

    repository - 领域驱动设计 - 作为存储库或服务的外部数据 API

    java - 我的方法在什么时候应该停止抛出异常?