Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 892741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:06:25+00:00 2026-05-15T14:06:25+00:00

I used git reset –hard dc082bc… to revert to the branch back to a

  • 0

I used

git reset --hard dc082bc... 

to revert to the branch back to a required previous state, due to some bad commits. This has rewound my local branch fine. However, I want to rewind the branch on ‘origin’ to the same commit so that I can start again. Could anyone tell me how to revert the origin branch (not master) to this commit?

I’ve tried git push origin master, but it gives the following error

 ! [rejected]        branch -> branch (non-fast-forward)
error: failed to push some refs to 'git@github.com:xxx/xxx.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:06:26+00:00Added an answer on May 15, 2026 at 2:06 pm

    You can try git push --force to force the push.

    --force
    

    Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check.
    This can cause the remote repository to lose commits; use it with care.

    So if lots of people have already pulled the same branch from origin, that can cause some rebase issue on their side.
    That operation can be blocked at the server side, like ebneter points out (in the comments):

    Depending on how the remote is configured, though, this may not work
    — all of my central repos are configured with receive.denyNonFastForwards = true and receive.denyDeletes = true, in which case any such surgery has to be done on the remote server.

    However, in the case of GitHub, such settings are not readily available for the user managing its GitHub repo.
    So if you git push --force by mistake, all you are left is opening a case to the GitHub support, for them to check their local (i.e. “GitHub”) reflogs and see if they can restore old commits.
    (Since reflogs are local, like I have been remembered recently. So commits which are replaced by new ones during a push --force are only still visible, if no ‘git gc‘ or ‘git prune‘ already took place, at the GitHub server side)

    So Marco Ceppi insists (in the comments):

    this could really mess up other contributors local repos if you force pushes – though are times that it is just a necessary evil (I’ve maybe had to do this two times in my lifespan of using Git)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used ( and still use ) mercurial and git. I have some repos
I have my branch on my GIT repository where I used to commit and
I was doing some work at home over the weekend and used git to
I used git checkout -b to create a new branch. I think that git
I've used Git for quite some time now, and I'm used to adding remotes
In git, to unstage a file git reset HEAD <filename> is used to discard
I have used git update-index --assume-unchanged on some files to keep my changes to
Was trying to commit some changes. I used git add to add any new
I used git filter-branch and screwed something up and accidentally rewrote sections of the
I've recently used git svn and enjoyed it very much. Now I'm starting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.