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 repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand 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 ... ```
From a terminal within VSCode, reset the remote to the URL (HTTPS or SSH) of the remote repository:
Check then the result of
git branch -avv
to check yourmy-branch
is indeed listed.