I have an Android "stored" in a Github repository. Now I did a complete rewrite of the app (started from fresh in another repository) - (how) is it possible to push the complete new repository to the existing one, but keeping it's commit history?
I guess I do not want to use the -f flag, as the commits are removed then. The best case would be to have the complete history of both repositories, but the code should only be from the new one.
Here's a brute-force approach (assuming you are working on the master branch):
Go to the old, original repo, rm -Rf everything but the .git directory. Then:
git add -u
git commit -m "starting over"
Then, define a remote for the old repo in your current repo:
git remote add origRepo oldUrl
git fetch origRepo
Then, create a temporary branch in your current repo and push your code:
git checkout -b tempBranch
git reset --hard origRepo/master
git merge master
git push origRepo tempBranch
Then on the original repo:
git fetch
git checkout master
git merge origin/tempBranch
git push origin master
You could also look into using an ours/theirs merge strategy if not every single file needs to be replaced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With