Sometimes I end up in following state, where the HEAD is not to be shown on the same commit as the master.
I suppose the HEAD must be checked out and following commits must go to HEAD. But how do I level both pointer on the same commit?
Sometimes I end up in following state, where the
HEAD
is not to be shown on the same commit as the master.
As mentioned in the comment above - read all about HEAD
here.
To answer your questions:
Everytime you change your repository state your HEAD
is modified and is updated and pointing to the current commit.
detached HEAD
is when the HEAD is pointing to any commit other than the latest commit.
In the described link you can read all about it and there is a detailed explanation what is head which im not going describe here.
Can you explain me this?
I changed some file being on
HEAD
, then I havecheckout master
and didgit svn rebase
which failed as there was the file changed.So I have reverted the changes and did git svn rebase still on master.
The resultHEAD
, master, git-svn are on the same commit.I actually did nothing and it is fixed now? How is that?
Lets break it into pieces and ill explain each piece:
I changed some file being on
HEAD
You can't do anything directly on HEAD. HEAD
is simply a reference to commit. Its a simple text file which store the SHA-1 of the commit which your current branch is now pointing to.
then I have
checkout master
Now your HEAD
is pointing to the latest commit on master.
... did
git svn rebase
... reverted the changes
Your HEAD
is back to its original value before the rebase - no changes should appear. (don't confuse it with the git revert
command)
The result
HEAD
, master, git-svn are on the same commit.
I actually did nothing and it is fixed now? How is that?
As explained above - look on it like this. You started to go on a walk (in this metaphor HEAD
is storing how far you are from the point you started to walk). you walked here and there (your rebase that you tried to do ) and then you decided you don't like the walk and you went back home. (you reverted the rebase). Now HEAD
is back in its original value since no "work" has been committed.