threads / discuss / 8478

Re: Git Vs. Svn for a project which *must* distribute binaries too.

Subject: Re: Git Vs. Svn for a project which *must* distribute binaries too.

## tl;dr

4 messages between Jun 7, 2007 and Jun 8, 2007.

replies: 3people: 3as markdown or json

linux@horizon.com· Jun 7, 2007, 04:36 UTC · lore

There's no reason that git can't do everything you have svn doing. What SVN calls "commit access" is what git refers to as "push access", but it's exactly the same thing. I don't see how it's the tiniest bit more difficult.

The only difference is that in git, it's a two-stage process: you commit locally, and then push that commit (or, more commonly, a whole chain of commits) when it's ready. But to the receiving repository, it's just another commit.

You can have a central server, just like you have with SVN, and when it gets new versions, it can auto-build them and do whatever it likes with the binaries. (Including stick them in the same git repository, or a different one.)

There's no need for such a central repository to be "owned" by one particular person. You can have a shared repository with multiple people having commit access. Linus likes to keep very tight security over his master repoisitory and only pull, but git supports a shared-access repository just fine.

The only thing, and it's not a very big thing, is that if you want fine-grained access control, you have to implement it yourself via the pre-receive hook rather than having a canned implementation ready.

As for making a binary of every commit, git encourages a slightly
different workflow:
- Because commits are very easy, and private (until pushed), you're
  encouraged to make lots of small commits.  I used to hold of committing to
  CVS if working on a big patch.  Now, I use git freely on a private branch
  to keep track of my own hacking.
  (git-gui is nice for encouraging me to commit frequently.  As I make
  edits, I write the commit message and watch the patch grow.  When it
  gets big enough, click "commit" and keep going.  I have a perfectly good
  memory, but after three phone calls, two "just a quick question"s and
  an impromptu meeting, the notes make it quicker to get back into it.)
- If you later decide the commits aren't something you want to show the world,
  then don't.  You can cherry-pick the good ideas and kill the lousy ones.
- The simplest example of this is "git commit --amend".  Git lets you
  commit before testing, and if you find some stupid typo that prevents
  the code from even compiling, you can just fix it and re-do the commit.
  *Poof*, your embarassing mistake just disappeared.
  (When learning git merges, it took me a log time to get over my fear of
  committing a mis-merge.  With git, it doesn't matter; it's just as
  easy to undo a commit as to do one, as long as you haven't published
  the results.)
- On the other hand, if you want to enjoy the full benefits of git-bisect,
  which can let J. Random Bug-submitter find the commit that caused a
  regression while you eat chilled grapes on the beach, you want both
  small commits and commits that don't break the build.  So cleaning up
  your history before publishing can be a very worthwhile effort.
  This is a step that many people aren't used to doing, and you don't
  need to force it on your developers.  Linus has long required such
  efforts, to make code review easier, but there are different traditions.
  But it really does make tracking down bugs a lot easier.

Anyway, because of the small-commit tendency, you might want to only build one binary per push, not one binary per version. (Oh, I should note that it is perfectly legal to push an old version that the receiving repository already has. It has no effect on the repository, but you could have it tickle your autobuilder. Check with someone who knows whether git even runs the commit hooks in that case, though.)

But you can do whatever. git-archive is a useful little tool for getting source snapshots to compile.

Once you've built the binary, you can, if you like, put it into a git branch by itself. You could even put it in the same repository as the sources, but with a totally disjoint history, but if you never intend to merge the branches, that just complicates your life and increases the chance that somebody will clone that branch. It makes more sense to use a separate repository.

Bryan Childs· Jun 7, 2007, 07:57 UTC · re: linux@horizon.com · lore
On 7 Jun 2007 00:36:32 -0400, linux@horizon.com <linux@horizon.com> wrote:
> There's no reason that git can't do everything you have svn doing.
> What SVN calls "commit access" is what git refers to as "push access",
> but it's exactly the same thing.  I don't see how it's the tiniest bit
> more difficult.
<snip>

Thanks for this extremely length and informative reply - it's answered all our concerns, and we may well move to git sooner rather than later now!

Bryan
linux@horizon.com· Jun 7, 2007, 16:51 UTC · re: Bryan Childs · lore
> Thanks for this extremely length and informative reply - it's answered
> all our concerns, and we may well move to git sooner rather than later
> now!

You're welcome. You just seemed to be under some misapprehension. Git can certainly do all the basic things that svn does, and just as easily.

You'll only have to learn more because you'll want to do more.

There are three big things that you'll want to get used to when coming from CVS or any other centralized version system:

1) Don't blink, you might miss it.  If you're used to CVS, you might
   wonder whether git actually *did* anything.  Commits, in particular,
   are instantaneous if the necessary data is cached in RAM, and it can
   take a while to learn to trust that everything worked.
2) Commits can be undone.  It can be a bit scary the way a command
   like git-rebase will make a whole bunch if repository changes and
   then maybe get stuck with a patch conflict.  You want to be
   comfortable undoing things, or amending commits if you're
   not happy with what happened.
   This is why novices (and I used to be one) are reassured by the
   existence of "git merge --no-commit", but experienced users don't
   see the point.
   With git, pushing (or asking someone else to pull) is the
   moment of truth.  Committing has no lasting consequences.
3) Branches are your friend.  CVS users think branches are a big
   deal and require careful thought and planning.  Git users branch
   almost as often as CVS users commit.  A typical "big change"
   that might be a single commit in CVS would be a branch of
   several commits in git.
   In fact, a good piece of advice is to NEVER commit directly
   to your trunk ("master").  Do ALL development on branches, and
   merge them into the trunk.
   I cheat on that a lot, but I also know how to fix things if I get
   caught becauee a quick hack is proving not so quick: add a branch
   reference to the tip I'm developing on and then back up the master
   branch to where I should have left it when I started this project.
Jan Hudec· Jun 8, 2007, 20:41 UTC · re: linux@horizon.com · lore
On Thu, Jun 07, 2007 at 12:51:50 -0400, linux@horizon.com wrote:
Show 14 quoted lines
> 3) Branches are your friend.  CVS users think branches are a big
>    deal and require careful thought and planning.  Git users branch
>    almost as often as CVS users commit.  A typical "big change"
>    that might be a single commit in CVS would be a branch of
>    several commits in git.
> 
>    In fact, a good piece of advice is to NEVER commit directly
>    to your trunk ("master").  Do ALL development on branches, and
>    merge them into the trunk.
> 
>    I cheat on that a lot, but I also know how to fix things if I get
>    caught becauee a quick hack is proving not so quick: add a branch
>    reference to the tip I'm developing on and then back up the master
>    branch to where I should have left it when I started this project.

There is a big difference between the cvs and subversion notion of branches and the git one, which make branches so much more friendly in git.

In cvs and subversion, branch name is part of the commit identity, so you have to create it before you commit and it will stay with you forever. That means you have to plan the branch, because there's no going back.

On the other hand git branch (head) names are just pointers to revisions you base your work on. You can add branch name after you commit, you can rename the branch anytime and you can delete branches that are no longer interesting, either because they are already merged, or because they didn't work out. That means you don't have to think twice whether you need a branch before you commit, since you can always change your mind later.

This makes it possible to use heaps of short-lived branches for experimenting and to give them silly names, because noone cares if you don't publish them, which you don't need to do and ususally won't do until you are confident that you are working in the right direction (at which point you have much better idea about what name to publish them under).

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

← back to recent threads