With git 2.9 (June 2016), merging orphan branches is still possible, but ony with the --allow-unrelated-histories
option:
git merge --allow-unrelated-histories a b
See commit e379fdf (18 Mar 2016) by Junio C Hamano (gitster
).
(Merged by Junio C Hamano -- gitster
-- in commit d04aa7e, 08 Apr 2016)
merge: refuse to create too cool a merge by default
While it makes sense to allow merging unrelated histories of two
projects that started independently into one, in the way "gitk
" was
merged to "git
" itself aka "the coolest merge ever", such a merge is
still an unusual event.
Worse, if somebody creates an independent history by starting from a tarball of an established project and sends a pull request to the original project, "git merge
" however happily creates such a merge without any sign of something unusual is happening.
Teach "git merge
" to refuse to create such a merge by default,
unless the user passes a new "--allow-unrelated-histories
" option to
tell it that the user is aware that two unrelated projects are
merged.
Because such a "two project merge" is a rare event, a configuration
option to always allow such a merge is not added.
The git merge
doc mentions:
By default, git merge
command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently.
As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added, and the list of options at the top of this documentation does not mention this option.
Also git pull
does not pass this option down to git merge
(instead, you git fetch
first, examine what you will be merging and then git merge
locally with this option).
See commit de22496 (21 Apr 2016) by Junio C Hamano (gitster
).
(Merged by Junio C Hamano -- gitster
-- in commit 175008d, 29 Apr 2016)
pull
: pass --allow-unrelated-histories
to "git merge
"
Instead of:
git fetch something &&
git merge --allow-unrelated-histories FETCH_HEAD
If somebody is inclined to add such an option, updated tests in this
change need to be adjusted back to:
git pull --allow-unrelated-histories something