I have a buggy master
branch that I need to debug. To do that, I want to insert a bunch of debug procedures (e.g., printing variables), pin point the bug and apply fixes. Later, I want to merge the fixes into the master
branch, but I want not to skip debug changes.
# create debug branch
git checkout -b debug
# ...
# edit sources and add debug prints
# ...
# commit debug changes
git commit --all
# create branch for the fix
git checkout -b fix
Now do the proper fix and commit
git commit --all
Go to master
branch...
git checkout master
...and merge with the fix without debug changes
git merge fix # <-- wrong, will merge debug changes as well
How to merge fix
without debug
?
What you are looking for is the 'onto' option of 'git rebase' (see 'git help rebase'). From what you described it would be:
git rebase --onto master debug fix
This actually re-roots the (from 'fix', to 'debug') commits at master. You still have the fix branch. To complete rework, follow up with:
git checkout master
git merge fix
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