Search code examples
gitgithubgit-commitgit-pushremote-repository

How to make HEAD and origin/master point to same (latest) revision. (HEAD points to latest while origin/master points past revision)


I'm new to git-hub.

I need to update my commit with -m "First" from local repo to git-hub.

Currently git log --oneline shows below stack.

394b23a (HEAD) First 895aa36 (origin/master, master) Second dc7346a Basic Service f627cd1 Data Binding. . . . If I try to git push origin master I get the message: "Everything up-to-date" and remote repo doesn't get updated. I think its because HEAD and origin are pointing to different revisions. I can't find a mean to merge both. I read about git merge but it mostly tells about merging two branches.

Please help to update the same. Thanks in advance.

NOTE: I have used git reset --hard HEAD in near past, which I think may be responsible for this mismatch.


Solution

  • git checkout 394b23a
    git branch master -f
    git checkout master
    git push origin master
    

    the HEAD is not stepping onto any branch, then above commands do:

    • checkout the target commit (you're already stepping there, but just in case)
    • move master pointer to that commit (no problem, since it is a forward move)
    • checkout master branch in order to be stepping onto it (for future commits)
    • push (no conflicts, no problems, just forward then OK)