After moving backward and forward to trace a bug in my repo, eg:
$ git reset --hard fcf9818
Found the bug then I wanted to move forward to the latest commit, eg:
$ git checkout 32764bf
Then, I started to make changes and want to commit it:
$ git status
HEAD detached at 32764bf
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
I thought I am the latest commit already?
But I went ahead to commit it:
$ git add -A
$ git commit
[detached HEAD ccf8009] Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
2 files changed, 6 insertions(+), 1 deletion(-)
Now I have this error:
$ 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>
What should I do it properly then if I want to forward to the latest commit after going backward?
How can I fix the error now?
EDIT:
$ git checkout 32764bf
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
6015d59 Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
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> 6015d59
HEAD is now at 32764bf... Added template for finally - only image.
And I still getting HEAD detached at 32764b
:
$ git status
HEAD detached at 32764bf
nothing to commit, working tree clean