簡體   English   中英

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'.

我對你們的問題是如何將我的更改推向高手?

只是挑選您的主分支上的提交:

git cherry-pick 2f1b645

您遇到的問題是,提交更改后您不在本地分支上。

順便說一句,您還可以重新設置基礎或合並提交。

git rebase 2f1b645

要么

git merge 2f1b645

可能需要重新設置基准,這將是最好的解決方案,但是由於我不確定100%確認了什么,因此選擇櫻桃是最安全的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM