I have written a blueprint for a Machine Learning pipeline that can be reused for many projects. When I encounter a new project, I will create a branch and work on the branch. Often times, when working on the branch, I discover the following:
I am having trouble in combining point 1 and 2. Is there a way to merge some changes from branch to main, it seems quite tricky to me as this is a continuous process.
If you are the only one working on that branch, you should do a git rebase -i (interactive rebase) in order to re-order your commits, putting first the one that should be merged to master, and leaving as most recent the one for branch only.
git switch myBranch
git rebase -i master
# reorder to get:
m--m--m
\
M--M--M1--b--b--b (myBranch)
Once that is done, create a branch at M1, and merge that branch to master
git switch -c tmp M1
git switch master
git merge b1
m--m--m--M--M--M1 (master)
\
b--b--b (myBranch)
Finally, force push your branch, since the rebase has rewritten its history
git switch myBranch
git push --force
(that is easiest done, again, if you are the only one working on that branch)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With