You are viewing a read-only archive of the Blogs.Harvard network. Learn more.

Topics in Version Control

versioncontrol-allthethingsThis last month I put together a presentation on version control. As far as I’m aware, everyone I work with uses some form of version control. My purpose with the presentation was many fold. I and a lot of thins that had been prrcelating that I wanted to think about and express. This as an excellent opportunity for that.

Git vs SVN

One thing I know is a sore point for some developers is the idea that git is taking over. There are a lot of people espousing the idea that git is better than svn in every way. This has created a conflict culture because there are a lot of developers making good use of svn and most have heard the primary arguments in favor of git and found the arguments are not compelling enough to motivate a switch.

This is okay.

There is no war on centralized version control, and if there is, the only people pushing it are dumbasses. (This coming from someone who was one such dumbass a couple years ago.)

It’s anti-agile to prescribe something like that. Each team works differently and needs to determine for themselves if the benefits outweigh the costs.

Continuous Delivery

Recently I read a book called continuous delivery. It is a comprehensive blowhard description of how devops “needs” to be. It covers testing strategies, and branching strategies. While a lopsided view of the world, it offered potential solutions that I have found fascinating.

Trunk Based Development vs Feature Branching

This offers not just a workflow that allows for potentially faster delivery, but also a realistic way to use SVN. An alternative to the branching hoopla around distributed systems.

DevOps

It also gave me an opportunity to talk about DevOps in a reasonably safe environment. It’s a political word at the moment and while I don’t want to get involved in that, I do want to talk about the DevOps movement.

This movement is about working together. Communicating on a level that hasn’t classically been done. It’s there because a lot of the problems we face are due to the fact that in our workflow, we develop a product and throw it over a virtual wall to operations to “handle”. They don’t understand what we need done and we don’t understand what they need done. It’s a matter of sharing knowledge and searching for a deeper understanding of what we’re doing. It’s hard because we don’t want to spread ourselves thin, but in order to deliver a quality product, you have to be more than just a cog in the machine. You don’t have to know exactly “how” to do everything, but you have to have a basic understanding of “what” is happening.

But I digress, I was able to tie this in to version control by talking about how DevOps is also concerned with automation. Creating scripts to do all parts of the deployments. These scripts, this automation needs to be in version control as well. They “can” be in the same repository, or they can be in a separate repository. But managing dependencies, flipping all the right switches, needs to be maintained in much the same way code is controlled. Because it is code.

Database Version Control

And of course, you can’t talk about Version Control without talking about database version control… but this one requires its own article.

Posted in Uncategorized. Tags: , , , . Comments Off on Topics in Version Control »

Using SVN with Git

I’ve talked about this before, but I made a pretty picture for it recently to help explain it.

SVN is a centralized repository that we use for controlling deployments, sensitive data, and storing environment specific configs. The majority of the code is contained within Git (github), the development, feature branching workflows etc.

This works well because SVN is good at being central and having a linear history. Git is good at branching and going nuts with workflow.

Posted in Git, SVN, Uncategorized, Version Control. Tags: , , , , . Comments Off on Using SVN with Git »

Git vs SVN again

My previous Git vs SVN made some errors based on old information. I’m hoping this will be a more accurate account.

Git Pros:

  • DVCS (Distributed Version Control System). What this means is it works off of the idea that every user copies the entire VCS and runs their own repository locally. This has several benefits.
    1. Speed. This makes development/working with the repository much faster as almost every operation does not require you to contact the “primary” repository.
    2. Tiny Commits. This allows / encourages tiny commits, so changes are tracked more closely and can be more easily separated out.
    3. Control over who merges. A merge can be attempted by any access layer, but this will generate a pull request which can then be reviewed and approved.
    4. No network access required.
  • Lightweight Branching. While feature branching in SVN is technically possible, it’s also a pain in the ass. Git made branching a first class feature. Easy branching means more people will probably make use of more advanced workflows.
  • Much smaller repositories. Due to better compression.
  • Repo file formats are simpler. So repair is easy and corruption is rare.
  • Clones act as full repository backups. That’s potentially useful I guess.
  • Creating a repository is trivial. So people who want to use repositories to track tiny personal projects, can just do so without any setup.

SVN Pros:

  • Narrow Clones. You can make a checkout of just one subdirectory deep in a hierarchy, download only the files related to that directory, and still be able to make commits. This seems useful in massively large repositories.
  • Authz files are easier (more standard) to write than Git commit hooks.
  • Comfort. People are already used to the linear structure and commands of SVN and that makes sense to them. Switching to DVCS is a cost. Most developers find the switch painful because it goes against what they’ve done for so long.
  • Deals with binary files better. If you’re tracking massive amounts of non-textual data, SVN handles it better as Git’s compression won’t work as well and it’ll be copying over everything.
  • Better classical / hierarchical model. (As opposed to patch/change based revisions.) It keeps in place a simplified model, good for keeping release history. Good for if you only make large commits and don’t want / need to record small dev changes. From a Git perspective, think of fast-forwarding every pull request.
  • SVN Lock. This provides more top down control over the repository.
  • Supports empty directories. This is probably important to someone.
  • Shorter and (mostly) predictable revision numbers.

SVN encourages large commits, Git encourages smaller commits. Simplicity or granularity. We all started out used to the former, but the latter is catching on quickly.

What seems to be the bottom line for most people is that SVN is the old and Git is the new. This is the direction of things, and it’s a new way of thinking about workflows and how VC can actually be doing things OTHER than just storing data.

The only issue that really matters to us is the pain of the switch. The problem is if we don’t understand the benefits that we’re getting from the switch, there’s never going to be enough of an impetus to switch.

Posted in Git, SVN, Version Control. Tags: , , . Comments Off on Git vs SVN again »

SVN vs Git

SVN is a minor improvement on the CVS design. A linear, central repository. To their credit, the developers of SVN acknowledge this, from the Red Book:

Subversion was designed to be a successor to CVS, and its originators set out to win the hearts of CVS users in two ways—by creating an open source system with a design (and “look and feel”) similar to CVS, and by attempting to avoid most of CVS’s noticeable flaws. While the result wasn’t—and isn’t—the next great evolution in version control design, Subversion is very powerful, very usable, and very flexible.

Git is a Distributed Version Control System (DVCS). It’s important to distinguish it as “decentralized”. What that means is that each user creates a literal “fork” of the project.

What Git offers that’s important is lightweight branching and significantly better merging. These are what make advanced workflows (feature branches) possible. See Git Flow.

Branching by itself isn’t where the magic is. What makes Git bounds above SVN is actually the merging. What makes the merging so much better is actually how the history of commits is kept. Git is a Directed Acyclic Graph (DAG) and SVN is done linearly.

What this means is the SVN merge doesn’t take into account previous merges of the branch, it merges the files directly. They’re both doing 3-way merges, but the 3rd that is used (the common ancestor) isn’t the same because the linear history of SVN isn’t taking into account previous merges. So basically SVN goes back way further because it doesn’t know where the last merge between branches was. The result is a lot more conflicts that have to be manually resolved.

The above is outdated. As of SVN version 1.5, (2008), SVN includes meta data on merge histories, so it uses the 3-way merge to similar effect as Git now. I’m going to have to write a new one of these after more research.

https://git.wiki.kernel.org/index.php/GitSvnComparsion
http://stackoverflow.com/questions/871/why-is-git-better-than-subversion/873#873
http://blog.evanweaver.com/2007/08/15/svn-branching-best-practices-in-practice/
http://stackoverflow.com/questions/2471606/how-and-or-why-is-merging-in-git-better-than-in-svn

Posted in Git, SVN, Uncategorized, Version Control. Tags: , , . Comments Off on SVN vs Git »

Using git with svn

If you have the choice, don’t. Pick one and stick with it. My personal preference at this time is git because it facilitates smaller commits — but who cares what I prefer, you’re probably tied to a versioning system based on what someone long before you decided to use.

I for one am tied to svn for doing deploys, but since I’m gaga over git and doing things in the open, I want to use git on a day to day basis and just use svn for deploys.

This sucks, but if you’re going to do it, you shouldn’t be a douche and add your .git directory to svn. That was my first attempt, even though I knew it was bad, I wanted to see the performance hit on svn firsthand I guess.

So I have the deployment related files in svn, so git is free of any environment specific files, like database configs.

So I do all development in git with “.svn” in the .gitignore. That part is easy. Getting svn to ignore git is a little more annoying, especially if you have multiple submodules. So when you’re ready, you add everything to svn, then rm the .git files. It’s better to rm them with the –keep-local flag.

If you delete the .git files because you forgot to –keep-local, or, more likely you’ve had to blow away your development and bring it back via svn, then you have to restore the .git files. Restoring them isn’t so bad:

git init
git remote add origin git@github.com/your_project.git
git pull origin master

Posted in ATG, Git, SVN, Version Control. Tags: , . Comments Off on Using git with svn »

SVN ignoring Git

The first thing I had to deal with was ignoring multiple files in one directory. I’ve always known

svn propset svn:ignore something.txt .

But if you then

svn propset svn:ignore something_else.txt .

it will lose the first ignore. The way to do multiple ignores is annoying:

svn propset svn:ignore "something.txt
> something_else.txt" .

It requires the “s and you have to separate the files with a newline. That’s silly.

So the right way seems to be with an svn ignore file. I created a file “.svnignore”:

.git
.gitignore
.gitmodules

(it doesn’t have to be called .svnignore, that just keeps it straight with me exactly what it is)

Then the following command needs to be run:

svn -R propset svn:ignore -F .svnignore .

and this will recursively run through every directory in “.” and ignore every pattern in the file. The only issue is any time new directories are added that contain git (i.e. submodules) the command will have to be re-run.

Posted in Git, SVN, Version Control. Tags: , , . 2 Comments »