skip to Main Content

For the past few days, I’ve been trying to push a branch to a private repo from VS Code with the GitLens extension, only to have it fail with the following cryptic message:

[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 repositorynfatal: Could not read from remote repository.nnPlease make sure you have the correct access rightsnand the repository exists.n"
}

I tried a reinstall of the extension, and setting the the (private) GitHub Enterprise Server URI in both User and Workspace settings. I also set the value of the github-enterprise.uri setting to "my.corporate.github.com/Organization" (with real values of course).

For the record:

  • VS Code version: Version: 1.73.1 (Universal) (Mac)
  • GitLens version: v13.1.1

So it’s clear that GitLens cannot find the name of the remote repo. How do I jog its memory?

For the record, some output from common commands (edited to avoid sensitive info):

$ git status
On branch my-branch
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   api/someFile.sh
    modified:   docker/docker-compose.yml
    modified:   docker/superfluous-edit.yml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    docker/all-containers.sh

no changes added to commit (use "git add" and/or "git commit -a")

$ git branch -avv | cat

  add-test-data       23411432 [origin/add-test-data] Refine name and add test data
  arm-docker-changes  a7c88c7a [origin/arm-docker-changes: behind 2] Remove stray fwd'ing of port
  master              b0b66b0b [origin/master: behind 3] Merge pull request #1653 from another_branch
* my-branch           df8a65e7 Merge to local
... more branch/commit descriptions, nothing else ...                                                           ```

2

Answers


  1. Chosen as BEST ANSWER

    As I suspected, it was a GitLens issue. I resolved it by just upgrading to a pre-release version (v2022.12.904) of that extension.

    Unfortunately, I don't have any more information as to what exactly went wrong. I did post an issue on GitLens' repo, however.


  2. From a terminal within VSCode, reset the remote to the URL (HTTPS or SSH) of the remote repository:

    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
    

    Check then the result of git branch -avv to check your my-branch is indeed listed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search