I attempted to merge 2 projects. Project_old and project_new. One which is ahead by a year into one which is behind. I put the projects into separate folders and did this in both of them:
git init
git add .
git commit -m "Initial commit"
I didn't make any backups of project_old, because I expected git to have it all in the repo in it's old state.
I then added a remote branch to project_old:
git remote add project_newer /path/to/project_new
git fetch project_newer
I then began to merge them both
git merge project_newer/master --allow-unrelated-histories
It produced some merge conflicts, so I fixed them with mergetool.
However, something went wrong with the merge and I ended up overwriting some important files from project_old with that of project_new, or so it seemed.
So I thought ok I will make a copy of project_old in it's failed merged state and do the checkout to initial commit's hash and do the merge again:
git checkout XXXXXX
But, for some reason, this commit only includes 10% of project_old which makes no sense whatsoever. I check the log with git log --stat
and I can see that only this 10% is included in the first commit. The next commit in the list is the "Initial commit" of project_new's repo, and the 3rd one is the merged final (the current master).
- Is there a way to return project_old to it's complete state it was in at the time of it's first commit?
- What went wrong so I can learn to not do this in future?