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

The Archive Base Latest Questions

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

I am using git / github and by accident I have been committing into

  • 0

I am using git / github and by accident I have been committing into “master” branch instead of “4.2”. I have now created a separate branch which is what “master” supposed to be, “4.1” and cherry-picked the essential commits.

Merges

I now want copy “4.1” into master to avoid the commits I’ve made on Nov1, 2, 3 and 7. What is the best way to do it?


I have tried to follow: Create git branch, and revert original to upstream state, but got this:

$ git push origin :master
remote: error: refusing to delete the current branch: refs/heads/master
To git@github.com:atk4/atk4.git
  • 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-26T18:00:35+00:00Added an answer on May 26, 2026 at 6:00 pm

    I’ve managed to restore by using this:

    # git back to my master branch
    git checkout master
    
    # reset branch to other branch
    git reset --hard 4.1
    
    # push changes and --force to avoid rejection
    git push --force origin master
    

    enter image description here

    Master is now the way it should have been. I wonder how will it affect clones who will “pull” master.

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

Sidebar

Related Questions

I have been using git and github with my small team of developers for
I am not using github. We have git setup on our machine. I created
I have a git repo in GitHub. I've been mostly using git gui to
I just started using git with github. I followed their instructions and ran into
I've been using git for some time now on Windows (with msysGit) and I
I have been using git to keep two copies of my project in sync,
We are using Git and our workflow consists of a 'dev' and 'master' branch
I have a Rails 3 app I'm developing with a team using Git/Github and
I am using git and I have two branches: production and master. At this
I am developing an app and version-control it using git at github. Now there

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.