[Phpwm] Version control - project organisation

Dave Brotherstone davegb at pobox.com
Fri Aug 28 10:37:29 UTC 2009


>
>
> >> Ian Munday wrote:
> >> Why Git?  I'm familiar with CVS and Subversion, but doesn't Git
> >> essentially provide the same functionality, albeit in a slightly
> >> different way (local versus centralised repositories)?
> >>
>
> David Goodwin wrote
>  >
> > My understanding (I've never really used git) was that it handles
> > branching and merging a lot better than subversion.
> >
> > I believe git can have a single centralised repository.
> >
>
>
Well, it can... but only because you deem one repository "special" /
centralised.
Branching and merging is far easier, faster and more reliable in git. So
good, in fact, that I (and many others) branch for any and every feature or
bug fix.
You may find that for your project it suits you better.

So you could have a central branch, and one for each client. When you do
something central, you can easily merge it into the client branches - you
could actually script this too, so one command would merge it into all your
client branches.

For clients that have more customisation, if you end up doing something for
client X that you later decide you want available to everyone, you can
"cherry pick" the commit into the central branch.

I work with SVN all day, and have done for years, but since working with
git, I hate the way svn works.  Everything in git is almost instantaneous,
you won't be waiting for any merges or "switches" (called a checkout in
git).  It's also pretty clever at merging things that have diverged.

I think doing the same thing in SVN would be perfectly possible, but you're
far more likely to get into difficulty, and end up with things not merged.
 There's also some really neat features that git can do, that SVN just plain
can't - stashing and rewriting history spring to mind.

A good reference is http://progit.org, which is a really good read.  I'll
stick an example on the end of this so you can see how it might work.

Hope that helps,

Dave.

An example....
> git branch
* central
  client1
  client2
  client3

(So we're currently on the central branch)

> git checkout client1
Switched to branch client1

> git branch
  central
* client1
  client2
  client3

(Now on the client1 branch, we'll edit the langs file)

> edit lang/en_GB.php
> git commit -a -m "Updated language file"
[central c8324b] Updated language file
 1 files changed, 3 insertions(+), 2 deletions(-)


( Now we'll edit something on the central branch)

> git checkout central
> edit src/someCentralFile.php
> git commit -a -m "Fixed a bug with xxx"
[central b91e7b2] Fixed a bug with xxx
 1 files changed, 5 insertions(+), 4 deletions(-)

( and go back to client1)
> git checkout client1

(now we'll check what's not been merged already)
> git branch --no-merged
  central
  client2
  client3

> git merge central
Automatic merge successful

> git branch --no-merged
   client2
   client3

(Now we'll create a new feature for client1)

> edit src/someExtraFeature.php
> git commit -a -m "Added a new feature for client1"
[central 944cb1] Added a new feature for client1
 1 files changed, 15 insertions(+), 1 deletions(-)

(Now we want that feature in the central branch)
> git checkout central
> git cherry-pick 944cb1
Automatic merge successful
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/phpwm/attachments/20090828/f6a07d09/attachment.htm 


More information about the Phpwm mailing list