Reputation: 123
1) I forked an 'original' repo, and started working on the 'forked' repo with other people
2) FastForward ~250 commits, and I change my github username, and also obtain a new no-reply email
3) I rebase all history to replace my name and email in each commit I'd made (believing I was only affecting my commits)
4) Force push into the remote forked repo, all the other teammates clone it from scratch and we keep moving
When attempting to submit a pull request to the original repo (step 1) I realize my rebase deleted all signatures that were made in the commits we cloned from the original repo. This caused almost the entire history to change, due to signatures being part of the commit hash. Now I'm 500 commits ahead and ~250 behind original/master
I want to grab the entire history of our work in 'forked' (commits after ~250) and rebase it on top of 'original' (this time, without altering their commits) so it can be merged into 'original'
In the final version, I would like to keep the history as is. All commits authored by who authored it, no squashing merge commits, and the likes. Is there any way to achieve that?
1) merge --allow-unrrelated-histories
git clone original-url
git remote add new-repo forked-url
git checkout -b new forked/master
git checkout master
git merge new --allow-unrrelated-histories
=> Leads to a working solution, but duplicates almost all original commits (without signatures) which I would like to avoid.
2) rebase
git clone original-url
git remote add new-repo forked-url
git checkout -b new forked/master
git rebase -i master
=> Leads to working solution, but the entire 'forked' history is ripped apart and replaced with a single line of commits (all merges are lost, all different tracks are lost). For instance, almost all my teammates collaborations are lost, as git interprets every commit as made by me. They don't even figure as contributors.
Upvotes: 1
Views: 330
Reputation: 1324148
Leads to working solution, but the entire 'forked' history is ripped apart and replaced with a single line of commits (all merges are lost, all different tracks are lost).
That is because you have done a simple rebase.
Try, preferably with the most recent Git version possible, a git rebase --rebase-merges
git rebase --rebase-merges master
That will transplant the whole topology of commit graph.
Upvotes: 1