Simple, powerful, beautiful websites.

My Guide to Git (Part I)

April 13, 2009

Git is a Version Control System, and I’m learning to use it.  What’s Version Control?  Well, it keeps track of all the different versions a set of files go through.  In the case of what I do, I track a site’s codebase starting on the day that I create it, and then I commit my changes as I make them.  This way, if I break a site, I can simply roll back to a working version of the site, and everything is A-OK.  Brilliant!  What follows are my notes from setting up Git on Windows.

Firstly, Web Designer Depot wrote an intro to Git that really got me started.  Much link love to them.  Next, there is a great visual tutorial over on github that has helped me alot with the Windows version.  Finally (at least for now) there is an interesting article about hosted git services on Drew Blas’ site.  Those links are useful.  Now, onto what I’m learning…

Creating a New Repository

There are two methods that I am combining together - the command line and the Git GUI.  Here is what I do:

  1. Navigate to the directory in Windows Explorer.
  2. Right click on it, and select Git Bash Here.
  3. In the terminal window, type:
    git init
  4. Now its a good idea to create an ignore file - since I use Dreamweaver primarily (there goes my developer street cred), I create a file called .gitignore with the content “_notes/*” (no quotes).  To do this, I type:
    notepad .gitignore
  5. Next, since we will be committing ALOT of files on the first go around (assuming there is an existing project already, which for me, there is!), type:
    git add .
  6. Now back out of the command line interface, returning to Windows Explorer.  Right click on the root directory and select “Git GUI Here.”
  7. You’ll see a set of Staged Changes, now just add a comment and hit Commit!
    From the command line, type:
    git commit -m “Message here”
  8. Its a good idea to tag the version as 1.0.0 (because its the first version in the repository), so:
    git tag v1.0.0

Creating a New Branch

This is what I’m learning right now.  Check out this Git cheat sheet, its super sweet!

2 Responses to “My Guide to Git (Part I)”

  1. Steve said:

    Just found this great guide - Git for the lazy.

  2. Steve said:

    You can simplify the remote pushing process by typing: ‘git remote’ to see your remote repositories, and ‘git push NAME’ to push to the remote repository.

    To add a new remote location, type ‘git remote add NAME address’. Nice!