Search code examples
gitgit-fetch

How to make the HEAD pointing to origin/master


I mistakely applied the branch on top of my master branch and committed the change. But now I want to make my HEAD point to the origin/master.

I have tried the below command :

git reset --hard origin/master

But my log shows the HEAD is pointed to master, origin/master, origin/HEAD, change-branch, etc.

enter image description here

How can I make my HEAD point only to (HEAD -> master, origin/master, origin/HEAD) not to change-ID like below?

Expected log :

enter image description here

Any help would be appreciated.


Solution

  • From your screenshot : it so happens that, at the moment, your two local branches change-494895-1 and 494895-1 point to the very same commit as master and origin/master.

    They won't interfere in any way with your work on master or on the rest of the repo. For example : next time you make a commit on master, or pull an update from origin/master, master will move forward, and these two branches won't.


    If you need to do something with those two branches :

    • if one of them is useless, just delete it : git branch -d <branch_name>
    • if you need to work on one of those branches : git checkout <brnach_name>; #some work; git commit
    • etc ...