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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:12:10+00:00 2026-05-26T06:12:10+00:00

I forked a project on github, made a new branch and made some changes

  • 0

I forked a project on github, made a new branch and made some changes (commits B, C and D) so I had the following tree:

... <-- A                     (master)
         \
          B <-- C <-- D       (branch2)

I mistakenly merged and deleted branch2 so now I had this tree:

... <-- A <-- B <-- C <-- D   (master)

However, I realized that I want to maintain a master branch that reflects the upstream changes and created myproject-master to have my work on that. I moved my commits by rebasing them to that new branch. After rebasing I deleted the <-- B <-- C <-- D part from the history on master by git reset --hard "A". I also squased C and D and I’ll refer to that commit as CD from now on. My problem is that I can’t push my changes on master and I have different trees in local and remote:

This is the local tree (what I want to have on both sides):

... <-- A                     (master)
         \
          B <-- CD            (myproject-master)

This is the remote tree:

... <-- A <-- B <-- C <-- D   (master)
         \
          B <-- CD            (myproject-master)

When I try to push on master, git rejects the push so I don’t lose data. Which is fine, but I already have those commits on the other branch and would like to clean them from the master. How can I do this?

  • 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-26T06:12:11+00:00Added an answer on May 26, 2026 at 6:12 am

    If you are the only person working on the repository, it’s safe to do a “force push” of your master branch to the remote repository, e.g. with:

    git checkout master
    git push -f myrepo master
    

    … but since that’s rewriting the history of the master branch, you will have to be more careful if you have any collaborators who have already pulled your master when it was ahead of A.

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

Sidebar

Related Questions

I forked a project on github, made some changes, so far so good. In
Someone forked a Github project of mine and made some changes. How can I
I am reasonably new to Git and recently forked a project from GitHub, made
I have a project I forked on github to my repository. I made changes
I forked a project on GitHub, pushed some changes, and opened a pull request.
I forked a project, made some changes, and got a pull request accepted. But
I have forked the git repository of a project on Github and made my
I forked a project on github. I made commit 1,2,3,4 & 5 on my
I forked some project and cloned it locally. Changed files, commited changes, pushed changes
So I forked a project, and made a few changes and pushed those to

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.