0
commit b438d02c93a4678276036cd8201e0e53774a2adb (HEAD)
Author: James <test@gmail.com>
Date:   Mon Jul 12 13:32:42 2021 +0100

    I fixed the input element on the user form

commit 684ec9c25e0320571173c29907029e9202950c43 (origin/master, master)
Author: James <test@gmail.com>
Date:   Mon Jul 12 11:57:43 2021 +0100

    I added user form

commit d65c75387d02b89a6d593522950480fbdcb7cc65
Author: James <test@gmail.com>
Date:   Wed Jul 7 17:32:08 2021 +0100

    update README
  • My head and origin are not aligned(embarrassing right?). I have checked-out to master git checkout 684ec. I commited I fixed the input element on the user form and pushed it to my remote(github) but got 'everything up to date'.

  • When I have git log I saw that it was committed on Head again which is not same as master.

  • As you can see I literally lost my head. How can I go back to master. I don't mind to give up on my last commit(I fixed the input element on the user form).

What should I do to go back to master and be well-organised?

PS I haven't opened branch because its my own personal project, no collaborators

Moyshe Zuchmir
  • 1,522
  • 12
  • 18
  • 2
    "I have checked-out to master `git checkout 684ec`" No. You've checked out *the commit* `master` happened to currently point at. Just get `master` to point at your new commit, now. With `git checkout master` then `git merge b438d02c9`, it will be a fast-forward, and you'll be set. – Romain Valeri Jul 13 '21 at 13:29
  • ... and HEAD is always where you are. So HEAD and a branch are not togetjer, it means you checked out something else, no embarrasment, actually. – eftshift0 Jul 13 '21 at 13:32
  • Does this answer your question? [How do I fix a Git detached head?](https://stackoverflow.com/questions/10228760/how-do-i-fix-a-git-detached-head) – matt Jul 13 '21 at 16:51

1 Answers1

0

A branch is just a pointer to a commit, but checking out that commit by hash isn't the same as checking out the branch.

You're detached, so just check out master now. Cherry-pick the missing commits if necessary.

isherwood
  • 58,414
  • 16
  • 114
  • 157