reddit / emacs

MAGIT Allow merging with unrelated histories

Extra_Armadillo7761 · 2022-05-22 13:09
My git Errors with “fatal: refusing to merge unrelated histories” So i've had this error a couple of times and i can't seem to fix it with magit. The following github issue says you can add it to the menu but the link goes to a blank page [https://github.com/magit/magit/issues/3633](https://github.com/magit/magit/issues/3633) The solution below works however i have to open terminal to use it, does anyone know how to add commands to the magit menu? [https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error](https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error)
[deleted] · 2022-05-22 15:08
[deleted]
joranvar · 2022-05-22 15:08
It looks like this can be done by using the `transient` library that is now used by magit. [https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients](https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients) After looking at a related page in the wiki that shows some examples ([https://github.com/magit/magit/wiki/Converting-popup-modifications-to-transient-modifications](https://github.com/magit/magit/wiki/Converting-popup-modifications-to-transient-modifications)), I came up with the following, which might be useful: (transient-append-suffix 'magit-merge "-s" '("-a" "Allow unrelated histories" "--allow-unrelated-histories")) It appends to the `magit-merge` prefix (submenu) after location "-s" (which is "Strategy") the suffix with keybinding `-a`, the given description and the given command-line argument.
Imaltont · 2022-05-22 15:52
You should be able to run the merge using --allow-unrelated-histories with a regular git command line call from magit, using ! by default. Doesn't look like magit itself exposes this flag though.