我一直在使用git submodule,当我收到此消息时,我已准备好推送我的更改:
$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
我运行以下命令,认为这可能已修复:
git checkout master
但我收到了这条消息:
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
2f1b645 my changes
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 2f1b645
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
我向你们提出的问题是如何将我的变化推向主人?
答案 0 :(得分:1)
只需在主分支上选择提交:
git cherry-pick 2f1b645
您遇到的问题是,当您提交更改时,您不在本地分支上。
顺便说一下,您也可以重新设置或合并您的提交。
git rebase 2f1b645
或
git merge 2f1b645
可能要改变它本来是最好的解决方案,但由于我不是百分之百确定你已经检查了什么,所以樱桃选择是最安全的方式。