[英]GIT: Not lossing changes after branch detached HEAD
我一直在git子模块中工作,当收到以下消息时,我准备推送更改:
$ 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'.
我对你们的问题是如何将我的更改推向高手?
只是挑选您的主分支上的提交:
git cherry-pick 2f1b645
您遇到的问题是,提交更改后您不在本地分支上。
顺便说一句,您还可以重新设置基础或合并提交。
git rebase 2f1b645
要么
git merge 2f1b645
可能需要重新设置基准,这将是最好的解决方案,但是由于我不确定100%确认了什么,因此选择樱桃是最安全的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.