Git click on a local branch with the same name as the remote tag

I am trying to push a new local branch of product-0.2 to the remote one where there is already a tag with the same name (but the branch itself does not exist)

 git push -v --tags --set-upstream origin product-0.2:product-0.2 Pushing to https://****@github.com/mycompany/product.git error: src refspec product-0.2 matches more than one. error: failed to push some refs to 'https://****@github.com/mycompany/product.git' 

Same:

 git push origin product-0.2:/refs/heads/product-0.2 

Although another way of working, for example, create a product-0.1 branch, commit to it, then apply the product-0.1 tag.

Some people work around this by deleting the conflicting tag locally, then push the branch, then retrieve the remote tag, but it seems cumbersome and error prone.

How can I create my branch with minimal clutter?

Thank you for your input.

+63
git git-branch
Feb 21 2018-12-21T00:
source share
5 answers

The following command should work.

 git push origin refs/heads/product-0.2:refs/heads/product-0.2 
+97
Feb 21 '12 at 17:38
source share

Change the names. If you do this locally or remotely, just change the names. The tag and branch are basically the same in git: they are a pointer to a commit. The difference is that the branch pointer advances when you commit, while the tag remains static. However, you can do a git checkout on a branch or tag. Why do you have to fight all these double names? Change them.

+13
Feb 21 '12 at 17:44
source share

Check which tags are associated with your branch:

 git tag 

In my case, I had a tag with the same branch name. Deleted:

 git tag -d [tag-name] 
+13
Apr 17 '15 at 16:09
source share

This morning I tried to push through the canonical repository and received the following error:

 $ git push origin master error: src refspec master matches more than one. error: failed to push some refs to 'ssh://user@host/srv/git/repo' 

This happened because I accidentally created a master tag locally:

 $ git tag master tag1 tag2 tag3 tag4 

As soon as I remove this tag locally:

 git tag -d master 

I could click again.

+2
Jun 01 '17 at 6:19 on 06:19
source share

This failed:

 git push $origin $branch:$branch 

So far this has worked for me:

 git checkout $branch git push $origin HEAD:$branch 
+1
Jan 29 '14 at 14:22
source share



All Articles