Introduction to GIT

Git is a free and open source, distributed revision control system, also commonly referred to as a version control system, designed to handle everything from small to very large projects with speed and efficiency. When developing code, A revision control system is useful in code because it acts as a method to share your code updates with a group, and keep track of your changes. It's a history of all your code work, and allows you to non-destructively edit your project without breaking it.

Version Control? Why do I need to use it>


Some of the best reasons:

  • It provides one method for an entire team to use; everybody operates under the same rules.
  • Changes are orderly vs. chaotic, saving development time
  • The ability to track changes promotes accountability, allowing you to contact the specific person who made an update.
  • A list of exact changes made can be viewed, making it easier to advise users of the information on how it has changed from version to version.
  • It gives you the ability to UNDO your changes!

Git's homepage: http://git-scm.com/. Git itself is an open source project that has been active for several years and is written mostly in C.

If you are new to coding, using GIT might feel like it's making your learning process more complex. But as you get used to using the command line and GIT, your code skill will become much stronger. Using a revision control system when coding allows you to jump into other open source projects with ease, and allows you to communicate the changes you're making to the group.

In order to use Git, you'll need to use the Terminal (on OSX). You can open the terminal by navigating to /Applications/Utilities/Terminal.

When setting up Git on a computer for the first time, here's some helpful commands to remember.

This is how you create a new Git project. Replace 'myproject' with your project name. 'mkdir' means you're creating a new directory, and 'cd' means you're moving to that directory. Typing 'git init .' means you're initializing a Git repository in the current directory.

mkdir myproject
cd myproject
git init .

Set up your name and email:
git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Use colors in Git:
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto

Add your files:
git add .

View your project status:
git status

Commit your changes:
git commit -m "A message about what I changed"

View your commit log:
git log


A helpful Git tutorial

Learning how to use Git properly takes a lot of patience, as it's like learning another language in addition to the language of your code. It is a VERY powerful tool. If you're stuck -- ask questions! It will begin to make much more sense as you become familiar and use it consistently. We'll be using it to share code and projects in our class.