0

I am working on a solo project and develop everything on master. I have made 2 commits and 2 pushes that I no longer want as my master branch. After running git log I find the id I need and run:

git reset --hard 36c75dccf125c1db6bc92f835cf1242010134f46 

This is the state of the code I need as my current master branch.

After running git commit -m "some-message" I see

your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch)

But I want this current state to be my main code on master branch. I do not want to git pull. What are the next steps?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Ben Shekhtman
  • 385
  • 5
  • 15
  • 1
    The commit command is useless after the reset, you should have had a message warning about commiting without staged changes (and suggesting `--allow-empty-commit` which is not your solution). About your main question, short answer is to push with `--force`, **but** there's a ton of duplicates for this question. Searching for a good one (thank you @mkrieger1, excellent one). – Romain Valeri Aug 17 '22 at 19:54

1 Answers1

1

Just push your changes (removal of two commits) to upstream.

git push

or, if required:

git push --force