Git - "debug" branch, merging "fix" branches without "debug"

I have a buggy master branch that I need to debug. To do this, I want to insert a bunch of debugging procedures (for example, print variables), indicate an error and apply corrections. Later I want to merge corrections into the master branch, but I do not want to skip debugging 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 correct fix and commit

 git commit --all 

Go to the master branch ...

 git checkout master 

... and combine with the fix without debugging changes

 git merge fix # <-- wrong, will merge debug changes as well 

How to merge fix without debug ?

+6
source share
1 answer

What you are looking for is the 'on' option for 'git rebase' (see 'git help rebase'). From what you described, it will be:

 git rebase --onto master debug fix 

This actually renames (from "fix", "debug") fixed to master. You still have a fix. To complete the revision, follow these steps:

 git checkout master git merge fix 
+7
source

All Articles