[LRUG] git question

Sam Livingston-Gray geeksam at gmail.com
Thu Aug 20 09:17:05 PDT 2009


Looks like you're well covered already, but...

On 20 Aug 2009, at 13:07:28 +0100, Taryn East <teast at globalpersonals.co.uk 
 > wrote:
> 2009/8/20 Chris Mear <chrismear at gmail.com>
>> If you can explain why you needed to pull out individual commits and
>> combine them into a patch, then we can suggest ways you can  
>> reorganise your
>> branches to make this easier in future.
>
> that's easy - because I was too much of a noob to know that I needed  
> to
> branch for each feature and was doing all my work on master ;)

One of the things I strongly prefer about Git over SVN is that I often  
have 2-5 different feature branches going at once.  With SVN, I got in  
the habit of keeping 2-5 complete checkouts of a given project,  
renaming the directories from "project_temp_1" to  
"project_spiffy_feature" as I went.  With Git, I create a new feature  
branch instead.  That way, if I need to put away what I'm working on  
and investigate something else, I can either use git stash, or (more  
often) just do 'git commit -a -m "WIP: adding spiffy new feature"'.   
Then check out the master branch, create a new branch (for the new  
thing), and I'm ready to look at a different problem in under a  
minute.  As a bonus, I can make tiny commits on the feature branch as  
I go, then squash them together into a bigger commit before merging  
them back into master.

Another side effect of cheap branches is that you can do trial  
merges:  create a new branch, merge, and if you hose something, switch  
back to your original feature branch and delete the one you just  
created.

In short:  Git makes it insanely easy to create tons of branches.   
Learn to use this fact to your advantage.  (=

Plug alert:  I've learned a lot from the two Peepcode products (one  
screencast, one PDF) that cover Git.  The "Git internals" PDF in  
particular makes for some surprisingly interesting reading.

Cheers,
-Sam (in PDX)




More information about the Chat mailing list