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 8739103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:52:01+00:00 2026-06-13T10:52:01+00:00

Several commits have been pushed to the origin branch. These commits contain code that

  • 0

Several commits have been pushed to the origin branch. These commits contain code that caused a problem. In order to fix the problem I did a git reset --hard <sha> to the commit before the problem started.

I have since fixed the problem and committed locally. Now I want to push to Origin but I cannot because my branch is behind Origin by 5 commits (that caused the problem) and ahead by 1 commit (the fixing commit). ie. diverged branches.

I do not want to merge in any of the changes from Origin. How can I set the head of Origin to that of my Local commit and without merging in the breaking commits into my Local branch?

Thanks!

  • 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-06-13T10:52:02+00:00Added an answer on June 13, 2026 at 10:52 am

    The clean way (that preserves history)

    1. create a local bugfix branch at your current commit
    2. checkout master (or whatever the origin is) and pull it fast-forward to the broken remote HEAD
    3. git revert the bad commits (everything between the last good sha where you forked, and the remote HEAD) … this removes the unwanted changes while preserving all the history
    4. merge your bugfix branch onto master: now all master’s changes have been reverted, this will be an easy merge

    The dirty way (discards history, discombobulates anyone else working on the remote branch)

    1. just use git push -f (double-check you have the right options & refspec) and hope no-one else has had their remote branch history change underneath them
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the following situation: several commits are pushed to a
I have two branches with several commits each. On one branch, I can go
I have several repositories that have been converted from SVN and moving forward we
If I have several commits made to the default branch since the last push,
I am currently trying to solve a problem, that I have using Hibernate 4
I have some objective-c code that uses an NSLock to implement a sort of
I have been tasked with refactoring a project that currently uses an EAV model
I have a project with several dependencies that are in various repositories. Each time
How do I view previous diff commits using Git? I have a file that
I just caused a problem that I'm having trouble finding a solution for. I

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.