About Git

- what is git as noted by phil glatz?
It's a distributed revision control system, and used to maintain files for
many open source projects (it's been part of Drupal for years). Kinda geeky,
but definitely not just for geeks any more.

What it lets you do is create a repository, containing files in a directory
and subdirectories. You have lots of control over what gets included and
excluded; for instance, you nay want to exclude caches, backup files, or other
content that is created automatically on the site.
You then add files to your project, and commit them to the archive. If you
change a file, you can commit your changes, and be able to see a history of
changes to the file. You can see the date of each commit, and what was changed
between commits. This is incredibly useful for programming, where you might
need to know why something stopped working.

Of course, this is most useful for text files. Obviously you're not going to
be able to view what changed in an image or video file, but you can revert to
earlier versions of them.

The next step is pushing your repo to a remote repository. You don't have to
do this, every copy of the repository is complete. But if you do have a remote
"master" repository, you can easily clone it to other computers, plus the
master acts as a kind of backup. I find this to be much more useful than a
general cloud backup, because you're saving the files associated with a
specific project.


Here's an example scenario - I work mostly on Drupal projects, and work on a
local copy of the site on my computer. I can make changes and test them
locally. Many times a simple change may affect a few templates, one or more
css files, and a module file. These all exist in different directories. Using
ftp, you would need to switch between directories to push your changes to
where they are located. It takes a bit of time to change between the
directories and push each file, with the possibility of error if you aren't in
the right place on both sides of your ftp. So during the push window, your
site will be unstable. And you might forget a file, or put in in the wrong
location.

With git, I commit my changes and push them to the master repository. The I go
to my remote server and do a pull. This is a single command, and git know
exactly which files have changed and where they are located. The transfer is
extremely fast and accurate.

Now suppose there are two other developers working on the project. They can
each have a local copy of the repository. If they make changes, they can check
against the master repo and find files that others may have changed, and merge
those changes into their copies. If two people were working on the same file,
git will automatically merge simple change; more complex ones can be dealt
with using a simple comparison tool. This solves a lot of problems!

You can also fork off a branch of the code base, make changes, test them, and
then merge your branch into the main code. This is useful if you're making
some radical changes, and don't want to disturb other developers until they
are correct.


The above is how useful git is for hard core developers, but it is also quite
useful for designers and others who just have a group of files associated with
a project they need to control. You can commit your files when milestones are
met, and be able to roll back to them at any time in the future, if you need
to see how they looked at a given time. You can also create branches to try
out different color or layout ideas. If you're using a remote repository as
your master, you have the advantages of having everything backed up, and also
the ability to make a copy of your project on any computer you use.

If you go with a commercial service for hosting your masters, I would consider
that a very reliable way to insure safe backups. They can't afford to lose
data or have security issues, and have teams of crack professionals that can
handle these concerns much better than most of us can.

I use two services for remote hosting, which have different models. The first
is sourcerepo.com; they charge by the amount of disk space you use, and there
are no limits on the number of projects you can have. I use this for smaller
projects, usually ones I don't share with other developers, because I can fit
many projects in the disk space.

My favorite is github.com; they are very big in the open source community, and
offer a lots of useful tools for file management, collaboration, and other
needs. Accounts are free, and you can have as many "public" projects as you
like; these are projects that anybody can access (although you can control who
can write to them). What you pay for with github is "private" projects, where
access is limited to those you designate.

Using git on a Unix-based system, like OSX, is extremely easy; it's already
built in to most systems. You can do everything from the command line in
terminal. There are also some free and commercial UI frontends for git; I
particularly like Tower. Github has a free UI for the Mac that's probably all
you need for most projects.


Revision control systems like this have been around for decades, starting with
cvs. Subversion was the tool of choice for many developers until git came
along. After a short learning curve, you'll be up and running, and wonder how
you got by without it!

Go to github.com and look at their tutorials. You will need to create a public
ssh key on your computer if you don't already have one, but that takes just a
minute and is well documented. Tower also has some good tutorials on their
site, and there are a number of git books, many for free and online.