我在下面遇到git问题...
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push master HEAD:<name-of-remote-branch>
我该怎么办?
答案 0 :(得分:0)
如果您确定自己在本地进行了正确的提交 ,则可以执行以下操作:
git push origin HEAD:master --force
然后,重要的是,通过以下方法将指针从分离的头更改为当前头:
git branch --force master HEAD
git checkout master
如果您要还原到以下名称为“ target commit”的先前提交(假设“ previous commit”不明确,可能是任何先前的提交),则假定您已执行以下步骤: >
git reset --hard <target commit>
您已通过以下方式签出了该提交的代码:
git checkout <target commit>
如果这样可以给您:
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
<unknown commit> revert to <target commit>
再次执行上面的git reset
命令!
如果git status
说:
HEAD detached at <target commit>
nothing to commit, working tree clean
当您准备好使用上面的命令推送时:
git push origin HEAD:master --force