I am trying to learn git by applying it (retroactively) to a project where I tracked a remote codebase for a while. When I put everything in git, I just created a remote branch for all external versions and put my versions in master , so currently my repository looks like this:
master: A0---A1.0--A1.1--A2.0--A2.1-.... \ remote: B1----------B2-----------....
My question is: how do I retroactively tell git about the merges that took place to make the repository look like (code should not change):
master: A0---A1.0--A1.1--A2.0--A2.1-.... \ / / remote: B1----------B2-----------....
Standard git disclaimer: no published story will be affected by the above steps :)
EDIT: The following is how I did it using the vaccinations suggested by Kevin:
First, I manually created .git / info / grafts as follows (all entries are sha1):
A1.0 A0 B1 A2.0 A1.1 B2
Then, checking that everything looks good (gitx), I ran git filter-branch with no arguments.
Filter-branch will make the transplants permanent and keep the refs in the original, fixed in refs/originals/... so that you can return via git reset --hard refs/originals/refs/heads/master . Since everything looked good, I removed all the leftovers as follows:
rm .git/info/grafts rm .git/refs/originals
If you have garbage collected, you need to do git update-ref -d refs/originals/refs/heads/master .
source share