Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push a commit that doesn't belong to any branch

Tags:

git

I have got a commit-id, currently it doesn't belong to any of the branch. It has got a label. How do I push this commit to server?

git show 2.0.rc10
tag 2.0.rc10
Tagger: ....
Date:   Fri Mar 29 13:38:55 2013 -0700
Release 2.0.rc10;  merged 
commit f1186bfeb938081f9d57f8ac20667329b1c53111

while running

git branch -r --contains f1186bfeb938081f9d57f8ac20667329b1c53111

there is no output.

How to push this commit to server?

git push origin 2.0.rc10
remote: Tag '2.0.rc10' references unknown objects. Push commits before tags.
To 
 ! [remote rejected] 2.0.rc10 -> 2.0.rc10 (pre-receive hook declined)
error: failed to push some refs to 'remote'
like image 368
user2397194 Avatar asked Jun 05 '15 05:06

user2397194


People also ask

How do you push to a branch that does not exist?

Create a new branch with git checkout -b <branch_name> , and push it with git push -u origin <branch_name> . Then, everyone can see your branch, and if you need to make changes to it, it's as straightforward as changing to the branch, committing, and pushing it up.

Does git push push to all branches?

No, git push only pushes commits from current local branch to remote branch that you specified in command.

Which command recovers commits that are not referenced by a branch or tag?

The git prune command is an internal housekeeping utility that cleans up unreachable or "orphaned" Git objects. Unreachable objects are those that are inaccessible by any refs. Any commit that cannot be accessed through a branch or tag is considered unreachable. git prune is generally not executed directly.


1 Answers

Your problem is not Git, but a pre-receive hook on the server that apparently checks that the commit is referenced by a branch.

Obviously, a solution is to push your branch first. I'm not sure why you would want a tag without a branch.

like image 56
Matthieu Moy Avatar answered Oct 03 '22 06:10

Matthieu Moy