This post is quite old now and might be irrelevant. I can recommend Get Started with Git on A List Apart by Al Shaw as a good introduction instead.
When I first tried to learn Git, I couldn’t wrap my head around it at all. It wasn’t because it’s particularly complicated (although it seems it), it’s because it didn’t fit with my workflow.
At the moment, your workflow might run as such
- Make changes to files
- Test locally or upload via FTP to a development account
- Upload via FTP to live site
Your workflow may differ, but fundamentally you edit, save and upload. Where does Git, or any other version control system, fit in? It doesn’t, and that’s why I never understood.
If you take the same workflow from above, but done the Git way.
- Make changes to files
- Test locally
- Tell Git what you’ve done
- Deploy from Git to live site
There’s no FTP involved. FTP means that files are moved from one place to another, but there’s no tracking. Git tracks every file, what changes are made, where it’s going and where it’s been.
You don’t have to use Git that way at all. You can still use Git to track changes in FTP, but it helps to understand the possibilities of Git if you can understand that you don’t need FTP.
The Git Application
When you install an application, you expect there to be something to open. Git isn’t that kind of application, it’s always there and you just have to tell it what to do. You do this from either the command line or a third-party application.
There are plenty of applications on Linux, Mac and Windows that work this way, but in the normal life of a computer user, they’re unlikely to bump into them. If you’re a web designer, Git might the first time you’ve had to use a command line. But as I mentioned, there are applications that do that job for you.
There’s two types of applications, there’s the web apps such as GitHub and desktop apps such as Tower for OS X. I’d argue that to begin with, you’re better off learning Git from the command line, as it’ll give you an understanding of what you’re actually doing, rather than playing around with the extra features of the app you’re using.
Most of the work you do using Git will be locally, so let’s start by installing Git on your local machine. Later, you’ll install it on a server or other remote host.
Installing Git on OS X
Download Git for OS X from Google Code. If you’re on a 64-bit Mac, you should choose x86_64 or if you’re on an 32-bit, choose i386 (How to tell if your Intel-based Mac has a 32-bit or 64-bit processor).
That’s it, Git’s installed! There’s no icon or anything, it’s installed onto your system.
The Command Line
So, the command line. You really don’t need much command line knowledge to use Git, but just incase you’ve never played around, here’s a quick tutorial.
Opening the command line
On Mac or Linux, open Terminal, found in Applications/Utilities. On Windows, open Command Prompt by pressing Start, Run, type ‘cmd’ and hit enter.
cd: change directory
It’s the same on Linux, Mac and Windows. To move about you use
cd, then followed by where you want to go. Type the name of a folder to open that folder, type
.. to up one folder. You can go as far up and down as you like, but using obliques between. If I’m in my Sites folder, and I want to go to public_html in my test_site folder, I simply type
$ cd test_site/public_html
Then to get back to the sites folder
$ cd ../..
ls: list files, or dir: show directory
This differs between Linux and Mac
ls and Windows
dir, but the idea is the same. Type
ls at the prompt and it’ll show you what’s in the folder. Here’s what happens if I run
ls from my home folder.
$ ls Desktop Downloads Library Music Public Documents Movies Pictures Sites
ls you can find your way around using the command line. You can always use FTP to connect remotely if you get stuck, or just look locally on your own computer, but Git will require you to know these two to move around.
If this feels a bit old school, that’s because it is. If you think I’m having you on, this is genuinely how development using Git (and a lot of other stuff) is done.