origin/xxx branches are always pointer to a remote. You cannot check them out as they're not pointer to your local repository (you only checkout the commit. That's why you won't see the name written in the command line interface branch marker, only the commit hash).

What you need to do to update the remote is to force push your local changes to master:

git checkout master
git reset --hard e3f1e37
git push --force origin master
# Then to prove it (it won't print any diff)
git diff master..origin/master
Answer from Simon Boudrias on Stack Overflow
🌐
Git
git-scm.com › docs › git-reset
Git - git-reset Documentation
You can use git reset to rewind history without changing the contents of your local files, and then successively use git add -p to interactively select which hunks to include into each commit, using git commit -c to pre-populate the commit message. $ git reset -N HEAD^ (1) $ git add -p (2) ...
Discussions

Artificially reset origin/HEAD to an earlier commit
Hi there. For a paedagogic purpose, I need to do something a bit uncommon and reset origin/master and origin/HEAD to an earlier commit, right after a… More on reddit.com
🌐 r/git
5
2
August 29, 2017
git - Resetting remote to a certain commit - Stack Overflow
I basically want to rewind my origin/master to ... Are you sure your origin/master has not been pulled and pushed to by other users? Changing history of a public (ie non-local) repository is something you want to avoid at all times. ... Save this answer. ... Show activity on this post. Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do: git reset ... More on stackoverflow.com
🌐 stackoverflow.com
Reset master to commit after pushing commits to the origin/master
So how can I continue with my local master and push to the origin? When I make a commit on my local master I get this situation: I obviously don't want to pull but I can't push neither (getting a message that I have to pull first). If I pull I go back to the commits I didn't want. How can I go on from the 'Last Commit before Upgrading SIS' (locally and remote)? ... Found an answer! ... https://stackoverflow.com/questions/48203597/git-fatal-error-occurs-while-trying-to-reset... More on community.atlassian.com
🌐 community.atlassian.com
January 11, 2018
How to switch to specific git commit?
Terminal git checkout Or use the extension "git graph" which you seem to have installed (icon left of refresh), find the commit right click and select "checkout..." More on reddit.com
🌐 r/vscode
5
2
January 21, 2024
🌐
Christian Engvall
christianengvall.se › git-reset-origin-master-to-commit
Git reset origin to commit | Christian Engvall
April 11, 2018 - Then use git reset –hard <commit-hash> to set the current branch HEAD to the commit you want. git reset --hard cedc856 git push --force origin master
🌐
Reddit
reddit.com › r/git › artificially reset origin/head to an earlier commit
r/git on Reddit: Artificially reset origin/HEAD to an earlier commit
August 29, 2017 - git update-ref refs/remotes/origin/master <commit-id> git update-ref refs/remotes/origin/HEAD <commit-id> git checkout master git reset --hard origin/master ... Excellent! It's exactly what I was looking for.
Top answer
1 of 11
1989

Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do:

 git reset --hard <commit-hash>
 git push -f origin master

However, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes. In that case, it would be better to revert the commits that you don't want, then push as normal.

Update: you've explained below that other people have pulled the changes that you've pushed, so it's better to create a new commit that reverts all of those changes. There's a nice explanation of your options for doing this in this answer from Jakub Narębski. Which one is most convenient depends on how many commits you want to revert, and which method makes most sense to you.

Since from your question it's clear that you have already used git reset --hard to reset your master branch, you may need to start by using git reset --hard ORIG_HEAD to move your branch back to where it was before. (As always with git reset --hard, make sure that git status is clean, that you're on the right branch and that you're aware of git reflog as a tool to recover apparently lost commits.) You should also check that ORIG_HEAD points to the right commit, with git show ORIG_HEAD.

Troubleshooting:

If you get a message like "! [remote rejected] a60f7d85 -> master (pre-receive hook declined)"

then you have to allow branch history rewriting for the specific branch. In BitBucket for example it said "Rewriting branch history is not allowed". There is a checkbox named Allow rewriting branch history which you have to check.

2 of 11
259

Most other answers – including the accepted one – will result in unnecessary loss of local state.

Local changes are not inherently required to change a remote. You may need to apply local corrections in addition to resetting a remote, but that's a lower priority if your problem is simply that you need to quickly put the remote back to how it was before your push, or you pushed the wrong thing. This method (like any other forced push) has the potential to ruin your remote if you choose the wrong commit, but even then you can usually find the correct one and try again.

You must have the desired commit somewhere in your local repo that the remote should match.

  1. Do not do any local resetting, checking out, or branch switching.

  2. Use git log to find the commit you want to the remote to be at. Use git log -p to see changes, or git log --graph --all --oneline --decorate to see a compact tree.

    If you cannot find the commit, try checking git reflog which will show the state history of your repo. You may be able to recover the commit from its hash, e.g.:

    git branch <name for branch of rescued commit> <hash of rescued commit>
    
  3. Copy the commit's hash, tag, or (if it's the tip) its branch name.

  4. Run a command like:

    git push --force <remote> <commit-ish>:<the remote branch>
    

    e.g.

    git push --force origin 606fdfaa33af1844c86f4267a136d4666e576cdc:main
    

    or

    git push --force staging v2.4.0b2:releases
    

If the forced push fails, it's likely disabled by the remote. This may be worked around by temporarily changing one or both of receive.denyNonFastForwards and receive.denyDeletes. If your remote is hosted on a service without shell access, it probably has settings you can change to allow forced pushes.


I use a convenient alias (git go, mnemonic "graph oneline") for viewing history, which can be added like so:

git config --global alias.go 'log --graph --oneline --all --decorate'
🌐
Atlassian Community
community.atlassian.com › q&a › sourcetree › questions › reset master to commit after pushing commits to the origin/master
Reset master to commit after pushing commits to the origin/master
January 11, 2018 - Otherwise, register and sign in. ... git checkout master git reset --hard e3f1e37 git push --force origin master # Then to prove it (it won't print any diff) git diff master..origin/master
🌐
Miketsamis
miketsamis.com › posts › git-faq-how-to-reset-origin-master-to-a-specific-commit
Git FAQ: How to Reset Origin/Master to a Specific Commit | MikeTsamis.com
November 26, 2018 - “git reset” will reset the current HEAD to a specified state. In this case, the state will be the commit hash which can be obtained by running “git log”. After resetting the HEAD, we can now force push our local changes to master.
Find elsewhere
🌐
Opensource.com
opensource.com › article › 18 › 6 › git-reset-revert-rebase-commands
How to reset, revert, and return to previous states in Git | Opensource.com
For most operations that modify pointers in this way, Git remembers the original commit for you. In fact, it stores it in a special reference named ORIG_HEAD within the .git repository directory. That path is a file containing the most recent reference before it was modified. If we cat the file, we can see its contents. $ cat .git/ORIG_HEAD 79768b891f47ce06f13456a7e222536ee47ad2fe · We could use the reset command, as before, to point back to the original chain.
🌐
Medium
devdiaryacademy.medium.com › git-rollback-resetting-a-branch-to-a-specific-commit-a-case-study-19daf94c2c78
Git Rollback: Resetting a Branch to a Specific Commit — A Case Study | by Developer Diary | Medium
February 10, 2026 - Replace <commit_id> with the actual commit ID you identified in Step 1. The git reset --hard command will reset your local "development" branch to the specified commit, discarding all commits made after it.
🌐
Atlassian
atlassian.com › git › tutorials › undoing changes › git reset
Git Reset | Atlassian Git Tutorial
Whereas reverting is designed to safely undo a public commit, git reset is designed to undo local changes to the Staging Index and Working Directory. Because of their distinct goals, the two commands are implemented differently: resetting completely removes a changeset, whereas reverting maintains the original changeset and uses a new commit to apply the undo.
🌐
W3Schools
w3schools.com › git › git_reset.asp
Git Reset
Use it to undo commits, unstage files, or clean up your history. git reset --soft <commit> - Move HEAD to commit, keep changes staged
🌐
freeCodeCamp
freecodecamp.org › news › git-reset-origin-how-to-reset-a-local-branch-to-remote-tracking-branch
Git Reset Origin – How to Reset a Local Branch to Remote Tracking Branch
June 22, 2022 - Usually, Git automatically assumes the remote repository’s name is origin. If you have a different remote name, replace origin with the name you are using. Now, reset the local main branch to the remote repository using the following command:
🌐
Educative
educative.io › answers › how-to-reset-a-git-branch-to-a-remote-repository
How to reset a Git branch to a remote repository
A Git branch can be reset to exactly ... · Fetch the remote branch and set your branch to match it: git fetch origin git reset --hard origin/master ·...
🌐
freeCodeCamp
freecodecamp.org › news › git-reset-to-remote-head-how-to-reset-a-remote-branch-to-origin
Git Reset to Remote Head – How to Reset a Remote Branch to Origin
September 10, 2024 - Now that you have background knowledge ... branch to origin using the git reset --hard command. Before you do this (if this your first time), make sure that you back up your branch before you reset it in case something goes wrong.
🌐
Linux find Examples
queirozf.com › entries › git-examples-resetting-undoing-and-reverting-changes
Git examples: Resetting, Undoing, and Reverting Changes
December 21, 2025 - $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: myfile.txt Untracked files: (use "git add <file>..." to include in what will be committed) myfile.txt
🌐
DeepDocs
deepdocs.dev › home › a developer’s guide to git reset hard origin
A Developer's Guide to Git Reset Hard Origin | DeepDocs
February 10, 2026 - TL;DR: How to Safely Use git reset --hard origin/ Table of Contents In short, git reset --hard origin/ is your local branch’s nuclear option. It forces your local code to perfectly mirror what’s on the remote server, completely wiping out ...
🌐
Linux Hint
linuxhint.com › reset-git-branch-origin-version
How to Reset Git Branch to Origin Version – Linux Hint
To reset the Git branch to the origin version, first, open the Git repository. Next, commit the current working of the branch by using the “git commit” command. After that, create a new backup branch that will automatically save the commits of the currently opened branch.
🌐
GitHub
docs.github.com › en › desktop › managing-commits › resetting-to-a-commit-in-github-desktop
Resetting to a commit in GitHub Desktop - GitHub Docs
If you made a series of commits and want to fix a mistake you made prior to the most recent commit, you can use "reset to commit" in GitHub Desktop to reset the changes in those commits. Resetting to a commit restores the changes in the subsequent commits to your working directory and resets the branch to the selected commit.
🌐
Medium
medium.com › @rogeriofbrito › git-reset-remote-repository-to-a-certain-commit-5cf4ced8882c
GIT: reset remote repository to a certain commit | by Rogério Ferreira Brito | Medium
August 24, 2019 - The first step is reset your local branch, using the command git reset [<mode>] [<commit>]. How we are reseting both working tree and index, we are use the mode — hard. The commit option is de commit id with is we wish back to.