So in an ideal world, when I started this project, I would have cloned from a source, and then committed all my changes to this repo. When the main project was updated, I could pull those changes into my repo. (This is one way traffic, no pushing going on.)
However, when I started, I did not clone, but simply downloaded a released ZIP of the code, unzipped it, and then did a git init
. I have since committed all my changes to this copy of the code. However, the main codebase has now been updated, but as my copy is not a merge, but my own repo of the same base code, I cannot merge the master's changes into mine.
Is there any way of getting these changes from the main code into my repo without having to start again?
You can fix your repository by rebasing the changes of your private repository on top of the remote changes.
git rebase
to transplant you commits on top of the remote commits.This would be something like:
cd $your_git_repository
git remote add origin $URL
git fetch origin
git branch -m my_branch
git rebase --onto $base_commit $your_first_commit my_branch
git merge $remote_branch
git log --graph --decorate --oneline
where $base_commit
is the commit corresponding to the zip you downloaded in the first place, and $your_first_commit
is the commit you commited the extracted zip file as.