Consider the following scenario:
I have developed a small experimental project A in its own Git repo. It has now matured, and I\'d like A to be part of larger projec
When you want to merge three or more projects in a single commit, do the steps as described in the other answers (remote add -f
, merge
). Then, (soft) reset the index to old head (where no merge happened). Add all files (git add -A
) and commit them (message "Merging projects A, B, C, and D into one project). This is now the commit-id of master.
Now, create .git/info/grafts
with following content:
Run git filter-branch -- head^..head head^2..head head^3..head
. If you have more than three branches, just add as much head^n..head
as you have branches. To update tags, append --tag-name-filter cat
. Do not always add that, because this might cause a rewrite of some commits. For details see man page of filter-branch, search for "grafts".
Now, your last commit has the right parents associated.