git - Picking the commits to merge with master -


say have buggy function in master branch:

def foo(x):    return 1/x git commit -a -m "foo created" 

i create new branch called bug debug it.

git checkout -b bug 

i create print statements debugging, , commit:

def foo(x):     print x     return 1/x git commit -a -m "print statements added debugging" 

finally bug fixed.

def foo(x):     print x     if x == 0:        return none     return 1/x git commit -a -m "foo bug fixed" 

now rebase second commit on bug branch master, don't add print statements (i.e. first commit), use interactive rebase follows:

git rebase -i master  drop b2296f0 printing pick 62beaa8 fixed 

and select second commit (i.e. bugfix), conflict:

def foo(x): <<<<<<< head =======     print x     if x == 0:         return none >>>>>>> 62beaa8... fixed     return 1/x 

is there way have git correct version, without me manually deleting debug print statements?

your checkout , rebase targets should other way around. rebase command can articulated wording effect of "unwind current position commit specified".

furthermore, you'll on feature/bugfix branch can ignore checkout , instead do

git rebase -i master

and pick/squash/fixup desired commits. when done can merge in:

git checkout master git merge bug

if instead want branch preserved in git tree can merge in specific merge commit (instead of doing fast-forward):

git merge --no-ff bug


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -