提交#10就是主人.然而,我最终意识到我在测试中没有遇到过的问题.
我最终将提交#5,然后慢慢重新执行每个提交的开发并不断调整它以确保它不会重新导致错误.现在我基本上回到了提交#10,但是有一些改变可以防止错误发生.
我现在想要使用我的更改创建提交#11.但是当我试图推动掌握时,我得到了
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>
Run Code Online (Sandbox Code Playgroud)
这是可以预料的.但是我如何才能真正实现这一目标呢?
我试过git push origin HEAD:master但后来得到了这个:
! [rejected] HEAD -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/tomhammond/sample.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
当我做的时候,git status我明白了HEAD detached from 4a74ac3
Tim*_*sen 82
但是当我试图推动掌握时,我得到了
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
这是可以预料的
除非你故意想要这样做,否则不要指望在一个独立的状态下工作,我怀疑你是这样的.您应该将master分支还原到该提交,或者git rebase以交互方式执行,您可以根据需要重新提交提交,而不是检查提交#5 .
话虽这么说,如果您确定master处于分离状态的版本是您真正想要保留的,那么您可以non-fast-forward通过强制将分支推送到远程来解决错误:
git push origin HEAD:master --force
Run Code Online (Sandbox Code Playgroud)
但是,如果您强行推送,则可能会导致所有其他已签出该分支的用户遇到问题.风险较小的解决方案是从分离的HEAD创建临时分支,然后将该分支合并到master:
git branch temp-branch
git checkout master
git merge temp-branch
git push origin master
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49708 次 |
| 最近记录: |