Making a Git push from a detached head

前端 未结 6 941
时光说笑
时光说笑 2020-11-29 20:05

I am on a detached head and made some changes. I want to push up these changed to this detached head with Git. I do not want my changes to go onto the develop branch and cer

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 21:03

    Note: making a branch before pushing is all the more recommended that git 2.11 or less used to segfault!

    This won't be the case with Git 2.12+ (Q1 2017)

    See commit b10731f (07 Jan 2017) by Kyle Meyer (kyleam).
    (Merged by Junio C Hamano -- gitster -- in commit b85f79c, 18 Jan 2017)

    branch_get_push: do not segfault when HEAD is detached

    "git @{push}" on a detached HEAD used to segfault; it has been corrected to error out with a message.

    The error now will be:

    HEAD does not point to a branch
    

    With Git 2.12 or more, you can then push your detached HEAD to a remote branch, as shown in Matt's answer.

提交回复
热议问题