Skip to content

Fail to push a tag that has the same name as the branch #2546

@Neko-Box-Coder

Description

@Neko-Box-Coder

Describe the bug
When trying to push a tag to remote that has the same branch name, it will fail with:

error: src refspec <tag name> matches more than one
error: failed to push some refs to <Remote git url>

Because it is using the command git push <remote> <tag name>, which doesn't specify it is pushing a tag.

To Reproduce
Steps to reproduce the behavior:

  1. Create a branch with an arbitrary name and push to remote
  2. Go to tag tab and create a tag with the same name as you created the branch
  3. Push the tag
  4. See error

Expected behavior
Tag should be pushed

Screenshots
None for now, can provide one if failed to reproduce.

Version info:
Run lazygit --version and paste the result here

commit=v0.36.0, build date=2022-11-15T07:26:07Z, build source=binaryRelease, version=0.36.0, os=linux, arch=amd64, git version=2.38.1

Run git --version and paste the result here
git version 2.38.1

Additional context
None for now.

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

Check code below, don't think it matters but can do so later if needed.

https://github.com/jesseduffield/lazygit/blob/82c54ed3d2339d2653dd8d06a39bcfb0d5e6cbe0/pkg/commands/git_commands/tag.go

func (self *TagCommands) Push(remoteName string, tagName string) error {
- return self.cmd.New(fmt.Sprintf("git push %s %s", self.cmd.Quote(remoteName), self.cmd.Quote(tagName))).PromptOnCredentialRequest().WithMutex(self.syncMutex).Run()
+ return self.cmd.New(fmt.Sprintf("git push %s tag %s", self.cmd.Quote(remoteName), self.cmd.Quote(tagName))).PromptOnCredentialRequest().WithMutex(self.syncMutex).Run()
}

See https://stackoverflow.com/a/52063091

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions