Skip to content

Git reset does not work properly when a tag and branch share name #4569

@ChrisMcD1

Description

@ChrisMcD1

Describe the bug
When you have a tag and branch with the same name (foobar) in my case, you cannot press g h on the branches tab to reset to the foobar branch.

To Reproduce

git init
git commit --allow-empty -m "Commit 1"
git tag foobar -m ""
git commit --allow-empty -m "Commit 2"
git branch -c foobar
git commit --allow-empty -m "Commit 3"

Launch LazyGit
Pres g h on branch foobar

Expected behavior
Expect to go to "Commit 2", and you actually go to "Commit 1"

Screenshots
If applicable, add screenshots to help explain your problem.

Version info:
Built off of latest master a0ec22c251c6
git version 2.49.0

Additional context
I'll put a fix in for this shortly, just documenting here for posterity. I'm assuming we just need to make our reset command use a slightly more specific name that disambiguates the two.
From the debug logs, it seems we just run a git reset --hard foobar. I imagine we'll just need to do a git reset --hard refs/heads/foobar as the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions