SlideShare a Scribd company logo
Introduction to Git
10/2/2013
Rick Umali
rickumali@gmail.com
@rickumali
http://tech.rickumali.com/
This presentation is on Google Drive at:
http://sn.im/git-talk-2013
There you can read the 'speaker notes' for this
presentation.
What is Source Control?
Source code control is the most important
practice a coding professional can do.
A mechanism to track changes in source code.
Used for version history, auditing, and
recovery.
Revision Control Example: Wiki
Revision Control Example: Git
You’ll learn how to make a repository like this.
Git
Git is an open source, distributed version
control system designed for speed and
efficiency.
Freedom
No "server" required
Unique architecture
Warning: Command Line Ahead
Our Example: A Basic Drupal Module
Creating a Repository
% cd web/sites/all/modules
% mkdir dumpstamp
% cd dumpstamp
% git init
"git init" creates the entire Git repository.
No server interaction required!
Committing Your First File
To 'commit' means 'to save the state' of your
work. You must first 'add' this change to the
'staging area'.
% vi README.txt
% git add README.txt
% git commit -m "First commit. README file."
Commit often!
Looking at the Repository History
% git log
% gitk
Adding More Files
% vi dumpstamp.info dumpstamp.module
% git status
% git add .
% git commit
or
% git commit -a -m “My commit message.”
Learn the shortcuts by reading Git docs.
Examining Changes to Files
% vi dumpstamp.module
% git status
% git diff
% git add dumpstamp.module
% git commit
% git log
Become familiar with Git status and diff
output.
Make your commit messages meaningful!
Looking at the Log Again
The history can be examined different ways.
% git log --format=short
% git log --format=oneline
% git log --oneline
Revisiting History
You can 'revisit' any point of your history.
% git checkout SHA_ID
Checkout makes the working directory match
the state of the specific SHA_ID.
This is a time machine!
Returning to the Present
At all times, Git retains a pointer to the
‘present’.
% git checkout master
Branching and Merging Next, But...
What we have covered so far is probably 70-
80% of what you will do with git.
Adding and committing files are the heart of
git (and any version control system).
Git encourages experimentation, by making
branching very easy!
Branching
Branching: git branch
% git branch BRANCH
% git checkout BRANCH
This makes a branch from “where you
currently are”, and then “switches” (checks
out) the branch.
“git branch” tells you what branch you’re on.
Branching: Starting State
SHA 1Amaster
NOTE: 'master' is a branch that's created 'by default'.
Branching: Make Some Changes
SHA 1A
SHA 2Bmaster
git commit
Branching: Making a Branch
SHA 1A
SHA 2Bmaster branch1
git branch branch1
git checkout branch1
OR git checkout -b branch1
Branching: Changes on the Branch
SHA 1A
SHA 2Bmaster
SHA 3C
(Make changes in "branch1".)
git commit
branch1
Branching: Making a New Branch
SHA 1A
SHA 2Bmaster
SHA 3C
git checkout master
git checkout -b branch2
branch1
branch2
Branching: Changes on another
Branch
SHA 1A
SHA 2Bmaster
branch2SHA 4D
(Make changes in "branch2".)
git commit
branch1 SHA 3C
Visualizing the Branches
Merging
Bringing two branches together.
First 'checkout' the branch you want to merge
into (typically master), then 'merge' in branch.
% git checkout master
% git merge BRANCH
Merging: Starting State
SHA 1A
SHA 2Bmaster
branch2SHA 4Dbranch1 SHA 3C
Merging: Fast-Forward Merge
git checkout master
git merge branch1
SHA 1A
SHA 2B
branch2SHA 4Cmaster, branch1 SHA 3C
Merging: Resolving Conflicts
git merge branch2
SHA 1A
SHA 2B
branch2SHA 4Cbranch1 SHA 3C
SHA 5 master
Merging: The Hard Part
Manual 'merging' may be required.
Visualizing the Merge
Whew!
Using Git “Remotely”
You can upload your local Git repository to a
public Git repository. These repositories are
known as remotes.
Using “remotes” is the key to collaborating.
Visualizing Remotes
Your Repo Bob Repo
GitHub Repo
Uploading New Code to GitHub
Create a repository (on GitHub).
Add a 'remote' (via git remote add).
Upload your code (via git push).
Creating a Repository
git init
Adding a Remote
git remote adds a name for a repo at a
specific URL
git remote add origin git@github.com:rickumali/DumpStamp.
git
Your Repo GitHub Repo
(origin)
Dumpstamp.git
This is just a naming step!
Push Your Repo to the Remote
% git push -u origin master
Visualizing the Push
git push uploads the repository to the remote
Your Repo GitHub Repo
(origin)
Visualizing Remotes (cloning)
Your Repo Bob Repo
GitHub Repo
(origin)
Now Bob can ‘clone’ your repository
clone
Cloning
After the Clone
The Cycle with Remotes
Your Repo Bob Repo
GitHub Repo
(origin)
You Push, Bob “Pulls” (or Fetches/Merges)
pullpush
You Saw and Learned A Lot About Git
Typical Git Commands
Add, Commit, Log, Diff, Status
Branch and Merging
Git Remote Repositories
Next Steps
Install Git
Commit frequently and log verbosely
Experiment (branch) often
Introduction to Git
10/2/2013
Rick Umali
rickumali@gmail.com
@rickumali
http://tech.rickumali.com/
This presentation is on Google Drive at:
http://sn.im/git-talk-2013
There you can read the 'speaker notes' for this
presentation.
Resources
http://sethrobertson.github.io/GitBestPractices/
Great list of Git best practices.
http://git-scm.org/
Both "Pro Git" book, and Git reference
http://gitref.org/
A "quicker" Git reference
http://www-cs-students.stanford.edu/~blynn/gitmagic/
"Friendlier" Git walk-through (git magic).
http://www.mail-archive.com/dri-devel@lists.
sourceforge.net/msg39091.html
Linus on "clean history."
Resources
http://www.youtube.com/watch?v=4XpnKHJAok8
Linus Torvalds (Git creator) (May '07)
http://www.youtube.com/watch?v=8dhZ9BXQgc4
Randal Schwartz (Perl expert and Git old-timer) (Oct
'07)
http://www.youtube.com/watch?v=ZDR433b0HJY
Scott Chacon (Pro Git author) (July '11)

More Related Content

What's hot (20)

KEY
The everyday developer's guide to version control with Git
E Carter
 
PPTX
Git & Github
Aman Lalpuria
 
PPTX
Workshop on Git and GitHub
DSCVSSUT
 
PDF
Git Tricks
Ivelina Dimova
 
PDF
Introduction to Git (part 1)
Salvatore Cordiano
 
PDF
Version Control System - Git
Carlo Bernaschina
 
PDF
Advanced Git
Sergiu-Ioan Ungur
 
PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
PDF
Git Tricks — git utilities that make life git easier
Christoph Matthies
 
PDF
Introduction to Git and Github
Houari ZEGAI
 
PPTX
Git and Github Session
GoogleDevelopersStud1
 
KEY
Git Basics at Rails Underground
Ariejan de Vroom
 
PDF
Recovering From Git Mistakes - Nina Zakharenko
Nina Zakharenko
 
PDF
Git-r-Done
Cesar Martinez
 
PDF
Git and GitHub crash course
Mireia Sangalo
 
PPTX
Git presentation
Sai Kumar Satapathy
 
PDF
Git - Get Ready To Use It
Daniel Kummer
 
PPTX
Git
IT Booze
 
PPTX
Stable master workflow with Gerrit Code Review
Luca Milanesio
 
PDF
Git Series. Episode 2. Merge, Upstream Commands and Tags
Mikhail Melnik
 
The everyday developer's guide to version control with Git
E Carter
 
Git & Github
Aman Lalpuria
 
Workshop on Git and GitHub
DSCVSSUT
 
Git Tricks
Ivelina Dimova
 
Introduction to Git (part 1)
Salvatore Cordiano
 
Version Control System - Git
Carlo Bernaschina
 
Advanced Git
Sergiu-Ioan Ungur
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
Git Tricks — git utilities that make life git easier
Christoph Matthies
 
Introduction to Git and Github
Houari ZEGAI
 
Git and Github Session
GoogleDevelopersStud1
 
Git Basics at Rails Underground
Ariejan de Vroom
 
Recovering From Git Mistakes - Nina Zakharenko
Nina Zakharenko
 
Git-r-Done
Cesar Martinez
 
Git and GitHub crash course
Mireia Sangalo
 
Git presentation
Sai Kumar Satapathy
 
Git - Get Ready To Use It
Daniel Kummer
 
Stable master workflow with Gerrit Code Review
Luca Milanesio
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Mikhail Melnik
 

Viewers also liked (20)

PDF
Finding Success: Social Media
Craig Daitch
 
PDF
SEO Analytics - Huzzah workshop
Ian Lurie
 
PDF
NZ Social Media State of the Nation 2015
Simon Young
 
PDF
How Nonprofit Communicators Combine Goals for 2013
Kivi Leroux Miller
 
PPS
Onddoak 1 T
ikasleak1t
 
PDF
NRG Shipping Solutions Overview
NRG Software
 
PDF
Ari Zilka Cluster Architecture Patterns
deimos
 
PPTX
My 2nd Grader's App Idea - Who wants in ? The road puzzle game
Shashi Bellamkonda
 
PPTX
Using GO's to Improve Student Learning
Jim Ellis
 
PDF
Experience Learning Live
darkwing1876
 
PPT
Bright Ideas
guest6acce3
 
PDF
Advanced SEO - Huzzah seminar
Ian Lurie
 
PDF
2007 development of a who growth reference for school aged children and adole...
Raul Rojas
 
PDF
The Black List - Vol. 1 - Social Media Masters
Michael Street
 
PPTX
Video Games and Reader's Advisory
Maggie Hommel Thomann
 
PPT
Day 2 2nd_weekcris
cristiarnau
 
PPT
Les riuades del segle XX
amestre4
 
PPT
Trends In New Media Luncheon at Optsum 2010
Shashi Bellamkonda
 
PPT
Survival Tips for Nonprofit Marketers
Kivi Leroux Miller
 
PDF
Setting Up Your Local Dev Environment
Rick Umali
 
Finding Success: Social Media
Craig Daitch
 
SEO Analytics - Huzzah workshop
Ian Lurie
 
NZ Social Media State of the Nation 2015
Simon Young
 
How Nonprofit Communicators Combine Goals for 2013
Kivi Leroux Miller
 
Onddoak 1 T
ikasleak1t
 
NRG Shipping Solutions Overview
NRG Software
 
Ari Zilka Cluster Architecture Patterns
deimos
 
My 2nd Grader's App Idea - Who wants in ? The road puzzle game
Shashi Bellamkonda
 
Using GO's to Improve Student Learning
Jim Ellis
 
Experience Learning Live
darkwing1876
 
Bright Ideas
guest6acce3
 
Advanced SEO - Huzzah seminar
Ian Lurie
 
2007 development of a who growth reference for school aged children and adole...
Raul Rojas
 
The Black List - Vol. 1 - Social Media Masters
Michael Street
 
Video Games and Reader's Advisory
Maggie Hommel Thomann
 
Day 2 2nd_weekcris
cristiarnau
 
Les riuades del segle XX
amestre4
 
Trends In New Media Luncheon at Optsum 2010
Shashi Bellamkonda
 
Survival Tips for Nonprofit Marketers
Kivi Leroux Miller
 
Setting Up Your Local Dev Environment
Rick Umali
 
Ad

Similar to Introduction to Git (20)

PDF
Getting Into Git
Rick Umali
 
PDF
Wokshop de Git
Alberto Leal
 
PDF
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko
 
PDF
Git
Mayank Patel
 
PPTX
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
PPTX
Hacktoberfest intro to Git and GitHub
DSC GVP
 
PDF
Subversion to Git Migration
Manish Chakravarty
 
ODP
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
PDF
Git slides
Nanyak S
 
ODP
Git presentation
Vikas Yaligar
 
PPTX
Introduction To Git Workshop
themystic_ca
 
PDF
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
PDF
Improving your workflow with git
Dídac Ríos
 
PDF
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
KEY
Git Tech Talk
Chris Johnson
 
KEY
Git Distributed Version Control System
Victor Wong
 
PDF
Git for Beginners
Rick Umali
 
PPT
GIT By Sivakrishna
Nyros Technologies
 
PPT
Github By Nyros Developer
Nyros Technologies
 
Getting Into Git
Rick Umali
 
Wokshop de Git
Alberto Leal
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko
 
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Subversion to Git Migration
Manish Chakravarty
 
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
Git slides
Nanyak S
 
Git presentation
Vikas Yaligar
 
Introduction To Git Workshop
themystic_ca
 
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
Improving your workflow with git
Dídac Ríos
 
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
Git Tech Talk
Chris Johnson
 
Git Distributed Version Control System
Victor Wong
 
Git for Beginners
Rick Umali
 
GIT By Sivakrishna
Nyros Technologies
 
Github By Nyros Developer
Nyros Technologies
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
July Patch Tuesday
Ivanti
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 

Introduction to Git