Git push commit which does not belong to any branch

I have a commit code, currently it does not belong to any of the branches. He has a shortcut. How to transfer this message to the 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

during work

git branch -r --contains f1186bfeb938081f9d57f8ac20667329b1c53111

no exit.

How to transfer this message to the 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'
+4
source share
3 answers

Your problem is not in Git, but on the server, on which, apparently, it is checked that the commit is bound by a branch.

Obviously, the solution is to insert your branch first. I'm not sure why you need a tag without a branch.

+1
source

, . , , , , yourbranch, :

git checkout yourbranch      # checkout the desired branch
git merge f1186bfe           # merge in the single commit
git push origin yourbranch   # push the branch out (with new commit) to the remote

, . , . , :

git show f1186bfe

, , , - :

git show 2.0.rc10

, SHA-1 , , :

git push origin 2.0.rc10
0
git push origin 2.0.rc10

, . 2.0.rc10, .

, , , , (pre-receive hook declined). , .

Some tests

Recovery situation with OP:

git checkout --orphan orphan_branch
git commit -am "stray commit"
git tag -a 2.0.rc10 -m "2.0.rc10"
git checkout master
git branch -D orphan_branch

Wandering Fixation:

git show 2.0.rc10
tag 2.0.rc10
Tagger: ...
Date:   Fri Jun 5 11:41:11 2015 +0200

2.0.rc10

commit 78e06b3a4841f88c1737ab8986fd6f3d753e1735
Author: ...
Date:   Fri Jun 5 11:41:00 2015 +0200

    stray commit

showing the stray commit

Click

git push origin 2.0.rc10
Username for ...
Password for ...
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 305 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To ...
 * [new tag]         2.0.rc10 -> 2.0.rc10

So, the lock is pressed, and the tag created on the remote control, since I do not have a hook for preliminary reception, it is pushed without problems.

0
source

All Articles