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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:26:34+00:00 2026-05-20T18:26:34+00:00

I’ve got a repo with two branches– master and dev. I was working on

  • 0

I’ve got a repo with two branches– master and dev. I was working on the master branch and pulled, and got a message that the repo was up to date. I committed my changes, and pushed to the remote repo (on github). I got a message saying that some changes were rejected.

I then did a git pull origin dev, which apparently was the wrong thing to do– since it merged the dev branch with my master, and like an idiot I didn’t notice this until I’d already pushed again. So the last commit shows Merge branch 'dev' of github.com:myuser/myrepo.

I can get back to the last known good status on my local repo by doing a git reset --hard [sha], with [sha] being the commit before the merge (though I’m not sure how to then make that change to the origin)– or from what I’ve read I can also do a git revert -m and then commit/push that change.

Can anyone walk me through the “right way” to undo my merge, and restore both branches back to where they were prior to the merge?

Thanks– if it matters this is a shared repo with only two developers, so it’s not under heavy changes.

Edit to add: please talk to me as if I were a child. I have to admit this Git stuff still confuses me, so I’m far from a power user! 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-05-20T18:26:34+00:00Added an answer on May 20, 2026 at 6:26 pm

    The git reset --hard [sha] will correct the branch on your local repository. To force this push to work, you can do a git push origin +master:master. The + sign will force the non-linear push to work.

    If the other developers have already pulled you wrong commit, they will have to do a git remote update, then a git reset --hard origin/master (provided that they are on their master branch, and have not made any other commits.

    Please use these commands with some caution :-). Good luck.

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

Sidebar

Related Questions

No related questions found

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.