Combine commits and push to forked repo

Issue

I have a repo (bitbucket.org/mine/project) which I forked from another repo (client.com/theirs/project). I made a bunch of commits to mine and now I want to push it back to their repo. I know I can push it to the upstream repo but it seems to include all the commits. My current workaround is I have both projects cloned and copying files from my repo working dir to their repo working dir and committing. Definitely not ideal. How do I squash my commits to a single commit when I push but leave my history intact?

Attempt to illustrate the issue:

Client       ---- forked ------>      Bitbucket

their/project                         mine/project

commit #A                             commit #A
commit #B                             commit #B
commit #C                             commit #C

                                  |-  commit #1
                                  |   commit #2
                                  |   commit #3
commit #D    <----- how? ------   |-  commit #4   // I want to keep my commits

Referenced:

https://help.github.com/articles/merging-an-upstream-repository-into-your-fork/#platform-mac

Combining multiple commits before pushing in Git

Solution

The owner of the their/project Github repo could always do this for you by choosing to Squash and Merge the commits from your branch via the Pull Request UI:

enter image description here

Answered By – Adil B

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published