I'm trying to learn git by applying it (retroactively) to a project where I have been tracking a remote codebase for a while.
When I put everything into git, I simply made a remote
branch for all the external versions and put my versions on 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 so (no code should be changed):
master: A0---A1.0--A1.1--A2.0--A2.1-....
\ / /
remote: B1----------B2-----------....
Standard git disclaimer: no published history will be affected by the above actions :)
EDIT: Below is how I did this using grafts as suggested by Kevin:
First, I manually created .git/info/grafts as follows (all entries are sha1's):
A1.0 A0 B1
A2.0 A1.1 B2
Then, after checking that things looked good (gitx), I ran git filter-branch
with no arguments.
Filter-branch
will make grafts permanent, and store refs to the original commits in refs/originals/...
to allow you to back out via git reset --hard refs/originals/refs/heads/master
. Since everything looked fine I removed all 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
instead.