benzen benzen - 1 month ago 5
Git Question

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)

Answer

Create a branch where you are, then switch to master and merge it:

git branch my-temporary-work
git checkout master
git merge my-temporary-work
Comments