On Thursday, September 12, 2013 11:47:02 PM UTC+4, GregH wrote:

What would be the steps required to achieve this?
> * create branch to work on a bug "branch1" from "master"
> * checkout "branch1"
> * make lots of changes to "branch1" putting in print statements all over 
> the place etc, but then identifying the actual issue & fixing 
> * in summary say then there are 20 changes in "branch1" but only 2 changes 
> (say one in two different files) are the bug fix itself
> Question is from this state how do a best with minimal work in git commit 
> just these 2 changes only back to the main branch?

Depends on what you really have on "branch1" and if you want to indicate
merging or are fine with just having the final changes back on "master".

If the final state of your "branch1" branch represents exactly
what you'd like to merge then I'd go with "squash merging":

git checkout master
git merge --squash branch1
... some massaging maybe ...
git commit

This would produce just one commit (*not* a merge) which just applies
the final state of "branch1" (as compared to "master") back onto "master".

If the final state of "branch1" is still dirty (littered with those debug 
statements etc) then before committing use `git reset --patch` to expunge
chunks which do debug printouts from the files as recorded in the staging
area after doing the squash merge.

If, instead, you'd like to indicate a merge, then you could first rebase
the master..branch1 commits (while on "branch1"), squash/remove some of them
and massage the final state, then merge "branch1" into "master" normally.

This would achieve a clear history on "branch1" and a fact the work has been
done elsewhere, not on "master" (some workflows insist on always merging
and always with --no-ff).

Note - Probably doesn't affect the answer but I'm using SourceTree as my 
> git GUI.

I have no idea how what I explained maps onto this tool but with you good 

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to