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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:49:41+00:00 2026-06-02T21:49:41+00:00

I’m working on a git repository that has a branch off of master, we’ll

  • 0

I’m working on a git repository that has a branch off of master, we’ll call it the ab branch. My team is working on the ab branch and has a pull-request workflow using github. One of my teammates made a pull request from his branch jeremy_ab_deletions to the ab branch. I was reviewing/testing his changes, but when I went to merge them into the ab branch I accidentally merged them into master instead and pushed master to github before I caught my mistake. Thinking I could just git-revert the change I did git revert SHA and it seemed to work…

I thought that had been enough and I happily switched back to my ab branch and continued working. Now, however, I realize that the previous commits from the ab branch which should never end up in master, are all in master. It’s…quite the mess. Since his branch was originally split off from ab, and then I merged it into master, I should have reverted it using git revert -m 1 SHA.

Today I was trying to figure out where exactly I went wrong and I’m all kinds of confused based on the git history, and my reflog. First, I tried reverting the reverts, and then doing git revert -m 1 SHA But git tells me:

fatal: Mainline was specified but commit 4c431c345dfe0a856967c090932c32f153824085 is not a merge.

So I think ok…maybe that wasn’t the merge commit and I need to target a different SHA. But looking at the history I can’t for the life of me figure out which one of these was the merge commit…

This was supposed to be on AB... 
…
d985b5bcf8 Browse code
Nathan B authored 8 days ago

This was supposed to be on AB... 
…
0e01911273 Browse code
Nathan B authored 8 days ago

removed unecessary tests
4c431c345d Browse code
Nathan B authored 8 days ago
Apr 17, 2012

removing un-used views and pages
a546f90ed3 Browse code
jeremychurch authored 10 days ago

The two commits that say “this was supposed to be on AB” are the revert commits to revert the ‘removed unecessary tests’ and ‘removing un-used views and pages’ commits. The next commit to master was today, and the commit before that was on the 16th, neither of which were related. I don’t see where the actual merge occurred.

I went through my reflog to see where exactly everything got messed up. I went went up and down the reflog versions using git reset --hard HEAD@{NUM} and then inspecting key files to see if the bad changes were in that spot yet. Finally I narrowed it down to these reflogs:

1fe2be2 HEAD@{79}: checkout: moving from 1fe2be29c6eda9f9fc9eb0b372ee83b7c15dfc2c to jeremy_ab_deletions
1fe2be2 HEAD@{80}: HEAD@{3}: updating HEAD
4c431c3 HEAD@{81}: HEAD@{1}: updating HEAD
47a97af HEAD@{82}: commit: removed unecessary tests, routes, and controller actions
4c431c3 HEAD@{83}: merge jeremy_ab_deletions: Fast-forward
1fe2be2 HEAD@{84}: checkout: moving from master to ab
d985b5b HEAD@{85}: revert: This was supposed to be on AB...
0e01911 HEAD@{86}: revert: This was supposed to be on AB...
4c431c3 HEAD@{87}: merge jeremy_ab_deletions: Fast-forward
c121a08 HEAD@{88}: checkout: moving from jeremy_ab_deletions to master
4c431c3 HEAD@{89}: commit: removed unecessary tests
a546f90 HEAD@{90}: checkout: moving from ab_page_changes to jeremy_ab_deletions
511b340 HEAD@{91}: checkout: moving from jeremy_ab_deletions to ab_page_changes
a546f90 HEAD@{92}: pull git@github.com:REDACTED/repo.git ab-remove-stuff: Fast-forward

Specifically HEAD@{88} here doesn’t have the bad commits, and HEAD@{87} does. Therefore it’s reasonable to assume I screwed up at the merge jeremy_ab_deletions: Fast-forward commit…… but I cannot figure out which ‘merge commit’ that would be. I tried this:

$ git revert -m 1 4c431c3
fatal: Mainline was specified but commit 4c431c345dfe0a856967c090932c32f153824085 is not a merge.

I…can’t find an actual merge commit it seems? Does anyone have any idea what I did wrong :/ I’m all kinds of lost right now.

  • 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-02T21:49:44+00:00Added an answer on June 2, 2026 at 9:49 pm

    If nobody else has pulled this master (or pulled but for certain hasn’t used it), this is what I would do:

    1. If no work was done on master since the ‘accident’, I would just reset it to the last good commit, and then update the remote master branch (by pushing with -f).
    2. If some work has been done, you can reset it to the last good commit, then use git rebase -i and delete the problematic commits, leaving the good ones in the list. Then again you’ll need to push (with -f).

    Alternatively, you can do all this in a new branch:

    1. Checkout the last good commit in master, create a branch there,
    2. Then use git rebase -i master to filter out the bad commits.
    3. Then you can go back to master and “merge” manually, bringing in all the changes from the new branch, and overwriting everything in master (you can use --no-commit and git checkout --theirs)
    4. push (without -f) the fixed master.

    Hope this helps! I hate mergencies.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.