Introduction to Git

Jeffrey Leek
Johns Hopkins Bloomberg School of Public Health

What is Version Control?

What is Version Control?

  • Many of us constantly create something, save it, change it, then save it again
  • Version (or revision) control is a means of managing this process in a reliable and efficient way
  • Especially important when collaborating with others

http://en.wikipedia.org/wiki/Revision_control

What is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

http://git-scm.com/

What is Git?

Download Git

  • Go to the following website and click on the download link for your operating system (Mac, Windows, Linux, etc):

http://git-scm.com/downloads

Install Git

  • Once the file is done downloading, open it up to begin the Git installation

Install Git

  • Unless you really know what you are doing, just go with the default options at each step of the installation

  • Once the install is complete, hit the "Finish" button (you may want to uncheck the box next to "Review ReleaseNotes.rtf")

Open Git Bash

  • Find a program called Git Bash, which is the command line environment for interacting with Git
  • It should be located in the directory into which Git was installed (or, for Windows users, in the Start Menu)

Open Git Bash

  • Once Git Bash opens, you'll see a short welcome message followed by the name of your computer and a dollar sign on the next line
  • The dollar sign means that it's your turn to type a command

Configure Username and Email

  • Each commit to a Git repository will be "tagged" with the username of the person who made the commit
  • Enter the following commands in Git Bash, one at a time, to set your username and email:
$ git config --global user.name "Your Name Here"
$ git config --global user.email "your_email@example.com"
  • You'll only have to do this once, but you can always change these down the road using the same commands

Configure Username and Email

  • Now type the following to confirm your changes (they may be listed toward the bottom):
$ git config --list

What's Next?

  • Go ahead and close Git Bash with following command:
$ exit
  • Now that Git is set up on your computer, we're ready to move on to GitHub, which is a web-based platform that lets you do some pretty cool stuff
  • Once GitHub is up and running, we'll show you how to start using these tools to your benefit