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.
Created by Linus Torvalds to aid in Linux kernel
development in 2005
History of Git
• Linux used DVCS called BitKeeper
• In 2005, Linux developers ran into BitKeeper licensing issue.
• April 5, 2005 - Linus Torvalds sends out email showing first version.
• June 15, 2005 - Git used for Linux version control
Initial goals:
Speed
Support for non-linear development (thousands of parallel
branches)
Fully distributed
Able to handle large projects like Linux efficiently
Version Control System
An application that allows you to record changes to your
codebase in a structured and controlled fashion.
A system that keeps records of your changes :
• Allows for collaborative development
• Allows you to know who made what changes and when
• Allows you to revert any changes and go back to a
previous state
Still what is GitHub ?
• GitHub.com is a site for online storage of Git repositories
• Founded in 2008
• Largest open source git hosting site
• User-centric rather than project-centric
• Hosts ‘remote repositories’
• Allows for code collaboration with anyone online
• Adds extra functionality on top of git
• UI, documentation, bug tracking, feature requests, pull requests,
and more!
• Octocat !
• Also has an Enterprise edition for businesses
Setting up Git
• Download and install the latest version of GitHub . This will
automatically install Git and keep it up-to-date for you.
• On your computer, open the Git Bash application.
• Tell Git your name so your commits will be properly labelled. Type
everything after the $ sign.
• Tell Git the email address that will be associated with your Git commits.
The email you specify should be the same one found in your email
settings.
Typical workflow
Person A
-Setup project & repo
-push code onto GitHub
-edit/commit
-edit/commit
-pull/push
Person B
-clone code from GitHub
-edit/commit/push
-edit…
-edit… commit
-pull/push
Terminology
• git - the shell command to work with Git
• repo - the repository where the code for a given project is kept.
• diff - difference between two versions of a file.
• master - the repository's main branch. Depending on the work flow it is the one people
work on or the one where the integration happens
• clone - copies an existing git repository, normally from some remote location to your
local environment.
• commit - submitting files to the repository (the local one); in other VCS it is often
referred to as "checkin"
• fetch or pull - is like "update" or "get latest" in other VCS. The difference between fetch
and pull is that pull combines both, fetching the latest code from a remote repo as well as
performs the merging.
• push - is used to submit the code to a remote repository
• remote - these are "remote" locations of your repository, normally on some central
server.
• head - is a reference to the node to which our working space of the repository currently
points.
Commands
git init
Initializes a new Git repository. If you want to place a project under revision control, this is the first
command you need to learn
git add
Moves changes from the working directory to the staging area. This gives you the opportunity to
prepare a snapshot before committing it to the official history.
git branch
This command is your general-purpose branch administration tool. It lets you create isolated
development environments within a single repository.
git checkout
In addition to checking out old commits and old file revisions, git checkout is also the means to
navigate existing branches. Combined with the basic Git commands, it’s a way to work on a
particular line of development.
git log
Lets you explore the previous revisions of a project. It provides several formatting options for displaying
committed snapshots.
git commit
Takes the staged snapshot and commits it to the project history. Combined with git add, this defines the
basic workflow for all Git users.
git push
It lets you move a local branch to another repository, which serves as a convenient way to publish
contributions.
git pull
It downloads a branch from a remote repository, then immediately merges it into the current branch.
git status
Displays the state of the working directory and the staged snapshot. You’ll want to run this in conjunction
with git add and git commit to see exactly what’s being included in the next snapshot.
git help
Forgot a command? Type this into the command line to bring up the 21 most common git commands.
You can also be more specific and type “git help init” or another term to figure out how to use and
configure a specific git command.
What is SSH?
SSH is a protocol used for secure network communication.
Getting files from Github
• Generate public/private keys
• Distribute public keys (add key to Github)
• Someone (GitHub) sends secure “message” (files) –
they encode with public key
• You receive the message/files – decode with private
key (only you know)
Putting files on GitHub
• Process is reversed to send files to GitHub
• You have the GitHub public key (see github_rsa.pub,
in Documents and Settings/Cyndi/.ssh on my machine)
• Use it to encode when sending
• GitHub uses their private key to decode