【问题标题】:Push to remote branch no longer working in VS Code with GitLens使用 GitLens 推送到远程分支不再在 VS Code 中工作
【发布时间】:2022-12-22 07:37:45
【问题描述】:

在过去的几天里,我一直在尝试使用 GitLens 扩展从 VS Code 将一个分支推送到一个私人仓库,结果却失败了,并显示以下神秘消息:

[2022-12-02 21:00:41.637] 
Failed to execute git {
  "exitCode": 128,
  "gitErrorCode": "RemoteConnectionError",
  "gitCommand": "push",
  "stdout": "",
  "stderr": "fatal: 'my-branch' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n"
}

我尝试重新安装扩展,并在用户和工作区设置中设置(私有)GitHub Enterprise Server URI。我还将 github-enterprise.uri 设置的值设置为“my.corporate.github.com/Organization”(当然是真实值)。

作为记录:

  • VS Code版本:版本:1.73.1(通用)(Mac)
  • GitLens 版本:v13.1.1

所以很明显 GitLens 找不到远程仓库的名称。我如何慢跑它的记忆?

【问题讨论】:

  • git remote -v 的输出看起来正常吗?如果你运行git push origin my-branch,你会得到同样的错误吗?

标签: git visual-studio-code gitlens


【解决方案1】:

从 VSCode 中的终端,将远程重置为远程存储库的 URL(HTTPS 或 SSH):

cd /path/to/local/repository
git remote set-url https://server/you/yourRepository
# or
git remote set-url origin git@server:you/yourRepository

# test it:
git fetch

然后检查 git branch -avv 的结果以检查您的 my-branch 是否确实列出。

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 1970-01-01
    • 2022-10-18
    • 2011-09-10
    • 2016-07-08
    • 2015-08-14
    • 2021-12-26
    • 2012-07-25
    • 2016-10-25
    相关资源
    最近更新 更多