skip to Main Content

I’ve initially created (by mistake) a local git branch named dev-doc which I later removed successfully.

Despite doing so, VS Code continues to show me the old name of the branch, while pointing the HEAD to the same ID of the new branch dev.

enter image description here

How can I get rid of the incorrect branch from the list?

I’ve checked the .git/config file without success.

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.hookspath=.husky
remote.origin.url=https://github.com/andreamoro/site.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.dev.url=https://github.com/dev/andreamoro.git
remote.dev.fetch=+refs/heads/*:refs/remotes/dev/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
pull.rebase=false

Nothing useful in the .vscode folder within the project too.
The git remote -v shows exactly one branch.

The git branch -avv however shows all that content shown by the IDE, but yet I don’t know from where this is taken.

* main                                               4046d17 [origin/main] fix: minor fixes
  remotes/dev-doc/feature/paginated-page-noindex     374a00c feat: prevent robots pages
  remotes/dev-doc/feature/update-documentation       6a1fb4b docs(readme): add deployment guidelines
  remotes/dev-doc/main                               324a8a2 Merge pull request #21 from dev/feature/paginated-page-noindex
  remotes/dev/feature/paginated-page-noindex         374a00c feat: prevent robots pages
  remotes/dev/feature/update-documentation           6a1fb4b docs(readme): add deployment guidelines
  remotes/dev/main                                   324a8a2 Merge pull request #21 from dev/feature/paginated-page-noindex
  remotes/origin/HEAD                                -> origin/main
  remotes/origin/feature/paginated-page-noindex      374a00c feat: prevent robots pages
  remotes/origin/main                                4046d17 fix: minor fixes

As you can see the remotes/dev/feature/update-documentation and remotes/dev-doc/feature/update-documentation are pointing to the same location.
I created the latter by mistake, then I created the first in the attempt to get rid of the first. Now they are both listed, but I need only one.
They are not a remote branch as I don’t have writing permission on that remote to create branches.

A git remote -v shows the following

dev https://github.com/xyz/repo.git (fetch)
dev https://github.com/xyz/repo.git (push)
origin  https://github.com/me/me-site.git (fetch)
origin  https://github.com/me/me-site.git (push)

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to the support of @user I figured out a reference in .git/refs/remotes remained in place from my previously created branch.

    Deleting the folder sorted out the problem.


  2. You had a leftover folder named dev-doc in your .git/refs/remotes folder. It’s weird that that was there, since the proper way of removing a remote is to do git remote remove <remote_name>, and through that approach, git will delete the corresponding folder in .git/refs/remotes, and remove all local information about remote branches from the removed remote (I know because I just tried it).

    Since your .git/config file looks unconventionally written, I’ll wager you were working with it by hand (nothing inherently wrong with that), but didn’t use the proper way (git remote remove) to remove the remote you added (you shouldn’t do that), and you instead just deleted the line that specifies the remote from your .git/config files.

    I wager that because you didn’t even know the difference between remotes and branches. I suggest reading the following:

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