GIT:分支分离 HEAD 后不会丢失更改
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'.
我想问你们的问题是如何将我的更改推送到 master?
只需在您的 master 分支上挑选那个提交:
git cherry-pick 2f1b645
你遇到的问题是当你提交更改时你不在本地分支上。
顺便说一下,您也可以重新设置或合并您的提交。
git rebase 2f1b645
或
git merge 2f1b645
可能将其变基是最好的解决方案,但由于我不能 100% 确定您已经检查过什么,所以选择樱桃是最安全的方法。
我一直在 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'.
我想问你们的问题是如何将我的更改推送到 master?
只需在您的 master 分支上挑选那个提交:
git cherry-pick 2f1b645
你遇到的问题是当你提交更改时你不在本地分支上。
顺便说一下,您也可以重新设置或合并您的提交。
git rebase 2f1b645
或
git merge 2f1b645
可能将其变基是最好的解决方案,但由于我不能 100% 确定您已经检查过什么,所以选择樱桃是最安全的方法。