1

I searched for similar questions posted here and on the web, but none of them refer to my case.

In some way, I accidentally created a duplicate local branch as you can see in the attached screenshot. git graph screenshot My guess is that I created it somehow when I was working with git stash with multiple stashes. This duplicate branch appears only locally. And moreover, the command git branch in this repo returns only the master branch.

How can I fix this and remove the duplicate local branch? I do want to keep the tags in their place (and I do see them in GitHub so they indeed exist in origin/master branch although they do not appear here in origin/master). Thank you for your help

Editing due to comments: Before all that mess I accidentally caused, I only saw a single line in the git graph (the blue one) and the tags appeared on it. there was no parallel line next to it showing the same commits. BTW, I cloned the repo to a new location and there I see what I expect - a single line with the tags appear on it. Moreover, I can't push to git from VSCode, but I do succeed in pushing from gitbash, this makes me wonder whether this is some bug in VSCode.

git log --all --graph --format=oneline --decorate prints the expected proper graph, with no duplication: enter image description here

mhadar
  • 49
  • 4
  • 4
    It's not a branch, it's a tag. – Romain Valeri Aug 02 '22 at 04:59
  • Like Romain said, it's a tag marking version 0.6.0. Did you rebase master? That would cause the apparent duplication. – Schwern Aug 02 '22 at 05:05
  • Before all that mess I accidentally caused, I only saw a single line in git graph (the blue one) and the tags appeared on it. there was no parallel line next to it showing the same commits. BTW, I cloned the repo to a new location and there I see what I expect - a single line with the tags appear on it. Moreover I can't push to git from VSCode, but I do succeed pushing from gitbash, this makes me wonder if whether this is some bug in VSCode. – mhadar Aug 02 '22 at 07:07
  • I'm not familiar with the log format you're looking at, but I'm not sure it's showing you everything. Specifically, I'd expect to see both `master` and `origin/master` somewhere in there, but I don't. Try `git log --all --graph --format=oneline --decorate` on the bash prompt and let us know what it outputs. – joanis Aug 02 '22 at 12:43
  • In any case, the kind of history duplication you are showing is what happens after a rebase. I suspect you'll have to take your recent commits and rebase them back onto origin/master before you can push a clean history again. – joanis Aug 02 '22 at 12:45
  • @joanis. `git log --all --graph --format=oneline --decorate` prints the properly expected graph (I will edit the question with the results). This makes me suspect some bug in VSCode. thank you! – mhadar Aug 03 '22 at 07:55
  • 1
    I'm afraid not... It looks like tag 0.6.0 is no longer a parent of `origin/master`. I think the problem is that `origin/master` was rebased and pushed, or else `0.6.0` is the result of a rebase, but you now have that duplicate history right on your server, not just locally. This is not a VSCode bug. Take the log command I gave you and keep scrolling until you find 0.6.0, you will see the same duplicate history there too. – joanis Aug 03 '22 at 15:06
  • 1
    TL;DR there is no duplicate local branch, there is no bug. Rather, `0.6.0` and `origin/master` have diverged through a rebase or cherry-pick operation. ... And I just read your answer, you figured it out and fixed you 0.6.0 tag. – joanis Aug 03 '22 at 15:08

2 Answers2

1

For other people facing the same issue.
I'm not sure why it happened but it was caused by the tags created using the git-graph extension in VSCode.
To fix this: manually deleted all tags locally only and then fetch them back using git fetch --all --tags.

mhadar
  • 49
  • 4
1

Note that if the tag was also pushed separately (possibly create/push by another collaborator), a git fetch --tags would bring it back.

While it was not the case for the OP, the command "Git: Delete remote tag" can help, and is introduced with VSCode 1.75 (Jan. 2023) with PR 170415 from the 2020 issue 104845.

This is available in VSCode Insiders today.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250