What to do with commit made in a detached head
Using git i made somthing like this
git clone
git checkout {a rev number tree rev before} (here i started to be in a detached head state)
//hacking
git commit
//hacking
git commit
(some commit where made on origin/master)
git pull (wich does complete because there was some error due to the fact that i'm no more on master)
Because git said to me that i can still commit when in a detached head state, I did so. But now i want to merge my detached head branch to my local master branch, and then push my changes to origin/master.
So my question is how could I merge the master branch with my actual state (detached head)
创建一个分支,然后切换到主并合并它:
git branch my-temporary-work
git checkout master
git merge my-temporary-work
You could do something like this.
# Create temporary branch for your detached head
git branch tmp
# Go to master
git checkout master
# Merge in commits from previously detached head
git merge tmp
# Delete temproary branch
git branch -d tmp
Even simpler would be
git checkout master
git merge HEAD@{1}
but this has the slight danger that if you do make a mistake it can be a little harder to recover the commits made on the detached head.
You can just do git merge <commit-number>
or git cherry-pick <commit> <commit> ...
As suggested by Ryan Stewart you may also create a branch from the current HEAD:
git branch brand-name
Or just a tag:
git tag tag-name
链接地址: http://www.djcxy.com/p/23516.html
上一篇: 查询git reflog以获取对特定文件的所有提交
下一篇: 如何处理独立头脑中的犯下行为