I have a modified Klipper installed on my 3D printer, but they didn't cleanly fork the original repo so I don't know on which revision they based their changes.
I would like to backport features from mainline to my printer modified version (replacing it as a whole is not an option) and I would like to know where to start.
How can I find the most likely mainline commit to start with? even dates are not useful for the purpose, I only know it's before a certain date (2024-05-10).
@phd I'm afraid there will be too much work, and my skills are limited. I was more planning to hand pick commits which both bring visible and usable improvements and which require little to no modifications to the code for merging.
The below sequence of commands puts both projects into the same Git repository (on your computer only) and then checks out the QIDITECH main
branch:
git clone https://github.com/Klipper3d/klipper
cd klipper
git remote add qiditech https://github.com/QIDITECH/klipper.git
git fetch --all
git checkout --track qiditech/main
This next command then cherry-picks the latest commit from the origin master
branch onto the branch you are on (i.e. the QIDITECH main branch, if you have just done the above):
git cherry-pick master
This happens to work right now, with QIDITECH/main at 653d7a8f6ec4700ec02c2319888ad98a92c1a0c3 and origin/master at fec3e685c92ef263a829a73510c74245d7772c03 - though you may well have to resolve conflicts or cherry-pick earlier commits first, or both, to get this to work in general.
It is very, very helpful to have a good graphical Git client, when dealing with complex branches. Fork is good, but expensive and doesn't work brilliantly with very large projects. gitk
is actually somewhat usable, though can also be somewhat hard to set up, e.g. on macOS (just because of obscure naming of the relevant packages) or on WSL. Many others are also available.
The above commands slightly rely on the fact that one project uses main
and one uses master
. If both projects used main
(or master
) you would have to rename the branches after checking them out, something like:
git clone https://github.com/Klipper3d/klipper
cd klipper
git branch -m origin_main
git remote add qiditech https://github.com/QIDITECH/klipper.git
git fetch --all
git checkout --track qiditech/main
git branch -m qiditech_main
git cherry-pick origin_main