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

  • SEARCH
  • Home
  • 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 361913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:11:41+00:00 2026-05-12T13:11:41+00:00

I had a repository that had some bad commits on it (D, E and

  • 0

I had a repository that had some bad commits on it (D, E and F for this example).

A-B-C-D-E-F master and origin/master

I’ve modified the local repository specifically with a git reset --hard. I took a branch before the reset so now I have a repo that looks like:

A-B-C master  
     \ D-E-F old_master

A-B-C-D-E-F origin/master

Now I needed some parts of those bad commits so I cherry picked the bits I needed and made some new commits so now I have the following locally:

A-B-C-G-H master
     \ D-E-F old_master

Now I want to push this state of affairs to the remote repo. However, when I try to do a git push Git politely gives me the brush off:

$ git push origin +master:master --force  
Total 0 (delta 0), reused 0 (delta 0)  
error: denying non-fast forward refs/heads/master (you should pull first)  
To git@git.example.com:myrepo.git  
! [remote rejected] master -> master (non-fast forward)  
error: failed to push some refs to 'git@git.example.com:myrepo.git'  

How do I get the remote repo to take the current state of the local repo?

  • 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-12T13:11:41+00:00Added an answer on May 12, 2026 at 1:11 pm

    If forcing a push doesn’t help (git push --force origin or git push --force origin master should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either receive.denyNonFastForwards config variable (see git config manpage for description), or via an update/pre-receive hook.

    With older Git you can work around that restriction by deleting git push origin :master (note the : before branch name) and then re-creating git push origin master given branch.

    If you can’t change this, then the only solution would be instead of rewriting history to create a commit reverting changes in D-E-F:

    A-B-C-D-E-F-[(D-E-F)^-1]   master
    
    A-B-C-D-E-F                origin/master
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 309k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I reached a point in my project were I was… May 13, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer I'd probably do something like this: public class MotionDetector {… May 13, 2026 at 10:03 pm
  • Editorial Team
    Editorial Team added an answer Is there any possibility to achieve such simplicity and readability… May 13, 2026 at 10:03 pm

Related Questions

Inspired by the DDD hype, I designed my classes pretending there was no database
Using SVN or Git the thought had occurred to me to use the directory
I've been using MVC frameworks for a short while now and I really like
I am wondering how should I be grouping my repositories? Like from the examples

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.