Reputation: 355
I tried to switch to another commit, so I did : git checkout 031c057
(fourth commit in order)
After I switched back to a06bbac
then I did some modification and I did a 'commit'
Now when I git status
I see :
$ git status
HEAD detached from a06bbac
nothing to commit, working tree clean
Here my git log :
f24cb85 (HEAD) seconde template
a06bbac (mostafa-test) sc just for test
19c2ad5 (origin/mostafa-test) first sample template
031c057 sc
f6c72a0 make component for table and header
89a0dd3 material-table ready
748ce3b first grid & first table
605562f (master) git ignore fix
1ec70f4 sc
eadfa97 (origin/master, origin/HEAD) Initial commit
How to make it normal ?
Upvotes: 1
Views: 2097
Reputation: 355
I think I found It :
First I kept my commit by : `git branch -f mostafa-test HEAD
Then : git checkout mostafa-test
It seems working !
Upvotes: 1
Reputation: 531315
HEAD
is a special symbolic reference. It's meant to refer to branch heads, not commits directly. When it refers to something that isn't a branch head, we say that HEAD
is in a detached state.
After you ran git checkout a06bbac
, your Git state resembled
HEAD ----------------> a06bbac ---> 19c2ad5 ---> ...
^
|
mostafa-test ------------+
rather than
HEAD ----> mostafa-test --> a06bbac ---> 19c2ad5 ---> ...
As a result, running git commit
did not update mostafa-test
as it should have.
To fix this, you can simply checkout mostafa-test
, then use git reset
to fix it.
$ git checkout mostafa-test
$ git reset f24cb85
Upvotes: 3
Reputation: 2409
It means HEAD is detached from a branch.
So when come back to a06bbac
, use git checkout mostafa-test
.
Normally HEAD is on a branch, not commit.
Upvotes: 0