As promised, I did a little info-seeking session to find out some information on Git. I’ve been hearing about it more and more as I’ve attempted to acquire coding skills, and this is what I’ve found out for others who are as clueless as I was.
What is Git?
Git is a distributed version control system allowing users to track the history of a collection of files by taking “snapshots” of the files at particular points in time. It doesn’t just store saved version, but rather takes snapshots of all the files at that point. That collection and their history is are stored in a repository.
The benefits to tracking the history is to allow for reversion to previous states, review changes made over time, see who modified it last, problem tracking, recovery, or simultaneous switching between two versions for testing purposes. Users can even clone entire repositories.
Clients check out a fully mirrored repository, so that if the server goes down, copies can be copied back up to the server to restore it.
Because most operations in Git only require local files and resources to operate, and you have the entire history of the project on your local disk, most operations are almost instantaneous and there is very little you can’t do offline. Users simply commit offline until they get to a network connection to upload.
According to Scott Chacon, it is important to understand that files reside in three main states – committed, modified, and staged.
Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
This means there are three main sections of a Git project: the Git directory, the working directory, and the staging area. Therefore, the basic workflow is something like this:
- Modify files in a working directory
- Stage the files, adding snapshots of them to your staging area
- Do a commit, which takes the files as they are in the staging area and stores that snapshot permanently in your Git directory
That’s the gist of it. Now is the point when I would install Git and get started (I avoided the obvious pun there). Git is an excellent resource I will definitely take advantage of when I begin working on web project from now on. I’m almost tempted to use it now for my grad school work, since I have nagging paranoia about storing all my files on my laptop and external hard drive.
Always the teacher, I also recommend this episode of O’Reilly Webcasts, “Git in One Hour” for my visual and hands-on learners.