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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:28:22+00:00 2026-06-06T18:28:22+00:00

I was working on a branch which was in the following state A’–B’–C’–D’ /

  • 0

I was working on a branch which was in the following state

        A'--B'--C'--D'
       /
A--B--C--D

some very bad things happened and I have to go back to B’ both locally and remote
so that the remote repository is the following

         A'--B'
        /
 A--B--C--D

For the local repository I did

git reset --hard <sha>

but how can I do that for the remote repository?

I should be able to do something like

git push origin mybranch –reset

but it’s not in the man page

I tried creating a commit which would cancel the previous ones but

git add .

reports that there are no changes (expected since I’m exactly after the previous push)

So how can I reset the remote repository?

  • 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-06T18:28:23+00:00Added an answer on June 6, 2026 at 6:28 pm

    Removing Commit from History

    All you really need to do is be on the B’ branch, and then go git push --force to overwrite the current commit pointer for that branch. If you don’t have your remotes set up as tracking branches, you may need to do git push --force origin <branchname> instead.

    C’ and D’ will remain in the reflog and as objects in the repository until they are eventually pruned, but shouldn’t show up as part of any log history unless you start digging into the plumbing.

    Removing Dangling Objects from the Repository

    If you want C’ and D’ out of the repository altogether, you can call git prune --expire now in both repositories. That should remove the dangling objects altogether.

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

Sidebar

Related Questions

When you branch some code, finish working with the branch, and merge it back
I have a typical problem which is like the following: 1) I was working
I have been working on a branch for a while, and deleted a directory
A co-worker and I are both working on the master branch at the moment.
My problem is that The code in the branch I'm working in for some
In CVS, my working copy (WC) is on a certain branch (which we'll call
We have multiple developers working on a project. We're employing a feature-branch method of
git version 1.7.3.5 I have the following branches: git branch image master * video
I was working on master branch, made some changes and then stashed them. Now,
I have a TFS environment with the following branching setup Dev - Primary working

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.