In Git, I can use the following syntax to push a specific commit to a specific remote branch:
git push remote COMMIT:branchname
However, this ONLY works if there is a local branch which references COMMIT. Is there a way to do this push for a commit, even if there is no ref that refers to it?
答案 0 :(得分:4)
The full spelling of a branch name is refs/heads/branchname
. When you push, if the destination ref doesn't begin with refs/
Git figures out what prefix you meant by looking at what you're pushing. But if there's a bare commit there, it has nothing to go on, so you have to specify the full spelling of the destination ref explicitly:
git push origin 54adf:refs/heads/branchname