Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - "debug" branch, merge "fix" branch without "debug"

Tags:

git

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?

like image 971
Jakub M. Avatar asked Mar 14 '13 21:03

Jakub M.


1 Answers

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
like image 80
GoZoner Avatar answered Oct 10 '22 04:10

GoZoner