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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:14:10+00:00 2026-06-12T09:14:10+00:00

So I forked a project in github, and cannot push my local changes to

  • 0

So I forked a project in github, and cannot push my local changes to my origin repo because of errors during the ‘push’ command requiring that I first do a ‘pull’. Well the problem is the ‘pull’ keeps overwriting all of my local commits.

Example shown below:

There is a project A (remote = upstream) on github that I forked into my own project (remote = origin). I then created a branch “branch_a” in which I added all my patch changes and pushed this branch to my remote origin repo. I ended up botching this whole process with multiple commits so I needed to squash my commits into one in order to submit a Pull Request to send my changes to project A. Attempts to squash my commits and synch with upstream repo went as follows:

git rebase -i upstream/master

I saw 4 commits and picked the one I wanted and removed the others

git push origin branch_a

Received error:

! [rejected] branch_a -> branch_a (non-fast-forward)
error: failed to push some refs to ‘https://github.com/#####/#####.git’
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. ‘git pull’) before pushing again. See the
‘Note about fast-forwards’ section of ‘git push –help’ for details.

Ran the pull command:

git pull origin branch_a

Received message:

  • branch branch_a -> FETCH_HEAD
    Merge made by recursive.
    libpex/INSTALL | 364 +++++++++++++++++++++++++++++++++++++++++++++++++++++
    1 files changed, 364 insertions(+), 0 deletions(-)
    create mode 100644 libpex/INSTALL

Local commit completely overridden by the pull command (I have tried to delete this file about 10 times but it keeps coming back).

So now I’m back to having 4 commits again and I cannot for the life of me push the correct commit back to my origin repo. What can I do about 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-06-12T09:14:11+00:00Added an answer on June 12, 2026 at 9:14 am

    If you want to tell Git to push what you have and overwrite whatever is at the destination (this can destroy history, so use it carefully) then supply --force to your push statement:

    git push --force origin branch_a
    

    This will cause the origin/branch_a branch to be updated to point at your local branch_a branch, regardless of whether or not it is a fast-forward. Any commits reachable from origin/branch_a that are not also reachable from your local branch_a branch or any other remote branch will be lost in the remote repository.

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

Sidebar

Related Questions

On github, I forked an old version of another project. I made some changes
I forked a project on github, since then the original owner made changes to
I'm wanting to fork a github project that other's have forked and one of
I forked a project on github, made some changes, so far so good. In
I've forked a project on GitHub that has some flash messages. For example, with
Someone forked a Github project of mine and made some changes. How can I
I forked a project on github, made a new branch and made some changes
I forked a project on GitHub, pushed some changes, and opened a pull request.
I have a project I forked on github to my repository. I made changes
So I first forked a repo and then made a commit to that forked

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.