SlideShare a Scribd company logo
1 of 31
Introduction To GIT
Rob Di Marco
Philly Linux Users Group
July 14, 2008
A Brief History of Git
• Linus uses BitKeeper to manage Linux code
• Ran into BitKeeper licensing issue
 Liked functionality
 Looked at CVS as how not to do things
• April 5, 2005 - Linus sends out email showing
first version
• June 15, 2005 - Git used for Linux version control
Git is Not an SCM
Never mind merging. It's not an SCM, it's a
distribution and archival mechanism. I bet
you could make a reasonable SCM on top
of it, though. Another way of looking at it is
to say that it's really a content-addressable
filesystem, used to track directory trees.
Linus Torvalds, 7 Apr 2005
http://lkml.org/lkml/2005/4/8/9
Centralized Version Control
• Traditional version control system
 Server with database
 Clients have a working version
• Examples
 CVS
 Subversion
 Visual Source Safe
• Challenges
 Multi-developer conflicts
 Client/server communication
Distributed Version Control
• Authoritative server by
convention only
• Every working
checkout is a
repository
• Get version control
even when detached
• Backups are trivial
• Other distributed
systems include
 Mercurial
 BitKeeper
 Darcs
 Bazaar
Git Advantages
• Resilience
 No one repository has more data than any other
• Speed
 Very fast operations compared to other VCS (I’m looking at you
CVS and Subversion)
• Space
 Compression can be done across repository not just per file
 Minimizes local size as well as push/pull data transfers
• Simplicity
 Object model is very simple
• Large userbase with robust tools
Some GIT Disadvantages
• Definite learning curve, especially for those used
to centralized systems
 Can sometimes seem overwhelming to learn
• Documentation mostly through man pages
• Windows support can be an issue
 Can use through Cygwin
 Also have the msysgit project
Git Architecture
• Index
 Stores information about current working directory and changes
made to it
• Object Database
 Blobs (files)
• Stored in .git/objects
• Indexed by unique hash
• All files are stored as blobs
 Trees (directories)
 Commits
• One object for every commit
• Contains hash of parent, name of author, time of commit, and hash
of the current tree
 Tags
Some Commands
• Getting a Repository
 git init
 git clone
• Commits
 git add
 git commit
• Getting information
 git help
 git status
 git diff
 git log
 git show
Our First Git Repository
• mkdir first-git-repo && cd first-
git-repo
• git init
 Creates the basic artifacts in the .git directory
• echo “Hello World” > hello.txt
• git add .
 Adds content to the index
 Index reflects the working version
 Must be run prior to a commit
• git commit -a -m ‘Check in number
one’
Key Git Files/Directories
• ~/.gitconfig
• .git
 In top level of repository
 Contains all objects, commits, configuration,
for project
 .git/config has project specific configurations
• .gitignore
 Stored in directory for ignoring
Working With Git
• echo “I love Git” >> hello.txt
• git diff
 Shows changes we have made
• git status
 Shows list of modified files
• git add hello.txt
• git diff
 No changes shown as diff compares to the index
• git diff HEAD
 Now can see the changes in working version
• git status
• git commit -m ‘Second commit’
Viewing What Has Changed
• git log
 Note the hash code for each commit.
• git show <OBJECT>
 Can use full or shortened hash
• git reflog to see all changes that have
occurred
Git and Patch files
• git diff HEAD^^
 Show what has changed in last two commits
• git diff HEAD~10..HEAD~2
 Show what changed between 10 commits ago and two
commits ago
• git format-patch HEAD^^..HEAD
 Will create individual patch files per commit
• git apply to apply patches
 git am to apply patches from an mbox
• Can also compare
 Between specific objects
 To branches/tags
Undoing What is Done
• git checkout
 Used to checkout a specific version/branch of the tree
• git reset
 Moves the tree back to a certain specified version
 Use the --force to ignore working changes
• git revert
 Reverts a commit
 Does not delete the commit object, just applies a
patch
 Reverts can themselves be reverted!
• Git never deletes a commit object
 It is very hard to shoot yourself in the foot!
Git and Tagging
• Tags are just human readable shortcuts for
hashes
• Branches can be made from any commit
• git tag <tag-name>
Branching
• Git branching is lightweight
 No massive copying a la CVS/Subversion
 Tools for helping merge branches and changes easily
• You are ALWAYS on a branch
• Branches can be local or remote
• Key commands
 git branch
 git merge
 git cherry-pick
• Allows you to choose specific commits to apply
• You can edit the commits while cherry picking
Using Branches
• git checkout -b branch
• git checkout -b devel/branch
• git branch
 Lists all local branches available
• We can now make changes in one branch
and propagate change using
 git merge
 git cherry-pick
Rebasing Example
• Simple branching
o--o--o <-- origin

a--b--c <-- mywork
Rebasing Example
• Work done on origin branch
o--o--O--o--o--o <-- origin

a--b--c <-- mywork
Rebasing Example
• Could merge changes into branch
• git merge origin
o--o--O--o--o--o <-- origin
 
a--b--c--m<-- mywork
Rebasing Example
• Rebasing moves branch point
• git rebase origin
o--o--O--o--o--o <-- origin

a`--b`--c`
Cleaning Up
• git fsck
 Checks object database to make sure all is
sane
 Can show information about dangling objects
• git gc
 Cleans up repository and compress files
 When used with --prune, cleans out dangling
blobs
 Can really speed up larger repositories
Using Remote
• Use git clone to replicate
repository
• Get changes with
 git fetch (fetches and
merges)
 git pull
• Propagate changes with
 git push
• Protocols
 Local filesystem
 SSH
 Rsync
 HTTP
 Git protocol
Cloning our Repository
• git clone first-git-repo
 Now have a full git repository to work with
• Changes are pushed back with git push
 Pushing changes WILL NOT change working copy on
the repository being worked on
• Branches can be based off of remote branches
 git branch --track new-branch remote/branch
• Remote configuration information stored in
.git/config
 Can have multiple remote backends!
Git for Software Versioning
• Create convention to define default server
• Developers clone from central server
• Lots of tools for transmitting patches between
developers
• Being used for
 Linux (obviously)
 Ruby On Rails
 Check out http://github.com for a variety of hosted
projects
Git for Backups
• Example: Directory needs regular backups
 Could use rsync but unwieldy in size
• Create Git repository for appropriate
directory
 Regular local commits
 Regular push to backup location
 Get simple revision heistory
Git for Configuration Management
• Example: Apache configurations
 Multiple environments (dev/test/production)
 Minor differences between environments
• IP Address
• Log levels
 Want to effectively move changes across
environments
Git and Other VCS
• Integrations with
 Subversion
 CVS
 Darcs
 Many others
• Example of integration with Subversion
 Use git-svn to fetch and commit push
• Note initial fetch may take a long time as each commit is
downloaded individually!
 Use git commands for everything
 Branches integrated with tags and branches
Some Git Coolness
• bash/zsh completion
• Gitk
 GUI to review changes
• git instaweb
 Used for starting HTTP process for browing
project
Further Resources
• http://git.or.cz/
 http://git.or.cz/course/cvs.html (For CVS
users)
 http://git.or.cz/course/svn.html (For SVN users)
• http://www.kernel.org/pub/software/scm/git/docs/user
• http://jonas.iki.fi/git_guides/HTML/git_guide/

More Related Content

What's hot

Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administrationShawn Doyle
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
 
GIT presentation
GIT presentationGIT presentation
GIT presentationNaim Latifi
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 
Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseHüseyin Ergin
 
Getting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersGetting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersNoam Kfir
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucketMedhat Dawoud
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 

What's hot (20)

Git basics
Git basicsGit basics
Git basics
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
Github
GithubGithub
Github
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
 
Git vs. Mercurial
Git vs. MercurialGit vs. Mercurial
Git vs. Mercurial
 
Git hub
Git hubGit hub
Git hub
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
 
Getting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersGetting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS Users
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 

Similar to Introduction to git

Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubKim Moir
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsGorav Singal
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAidan Casey
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to GitMuhil Vannan
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptxEshaan35
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Ahmed El-Arabawy
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the starsStrannik_2013
 
O365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van RousseltO365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van RousseltNCCOMMS
 
Introduction to Git for Network Engineers
Introduction to Git for Network EngineersIntroduction to Git for Network Engineers
Introduction to Git for Network EngineersJoel W. King
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthroughBimal Jain
 
Git and GitHub (1).pptx
Git and GitHub (1).pptxGit and GitHub (1).pptx
Git and GitHub (1).pptxBetelAddisu
 

Similar to Introduction to git (20)

Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Git
GitGit
Git
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
 
O365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van RousseltO365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van Rousselt
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introduction to Git for Network Engineers
Introduction to Git for Network EngineersIntroduction to Git for Network Engineers
Introduction to Git for Network Engineers
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Git and GitHub (1).pptx
Git and GitHub (1).pptxGit and GitHub (1).pptx
Git and GitHub (1).pptx
 

More from Nguyen Van Hung

Cai dat va_cau_hinh_iptables
Cai dat va_cau_hinh_iptablesCai dat va_cau_hinh_iptables
Cai dat va_cau_hinh_iptablesNguyen Van Hung
 
So sánh asp.net và mvc
So sánh asp.net và mvcSo sánh asp.net và mvc
So sánh asp.net và mvcNguyen Van Hung
 
Cong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatCong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatNguyen Van Hung
 
Cong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatCong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatNguyen Van Hung
 
Asp net mvc3 music store egroups vn
Asp net mvc3 music store   egroups vnAsp net mvc3 music store   egroups vn
Asp net mvc3 music store egroups vnNguyen Van Hung
 
Asp.net mvc 3 (c#) (9 tutorials) egroups vn
Asp.net mvc 3 (c#) (9 tutorials)   egroups vnAsp.net mvc 3 (c#) (9 tutorials)   egroups vn
Asp.net mvc 3 (c#) (9 tutorials) egroups vnNguyen Van Hung
 
Cau truc dl_va_giai_thuat_bai1[1] - copy
Cau truc dl_va_giai_thuat_bai1[1] - copyCau truc dl_va_giai_thuat_bai1[1] - copy
Cau truc dl_va_giai_thuat_bai1[1] - copyNguyen Van Hung
 
Thạch quyển và các dạng địa hình
Thạch quyển và các dạng địa hìnhThạch quyển và các dạng địa hình
Thạch quyển và các dạng địa hìnhNguyen Van Hung
 
Bài tập về chuẩn hóa chuỗ1
Bài tập về chuẩn hóa chuỗ1Bài tập về chuẩn hóa chuỗ1
Bài tập về chuẩn hóa chuỗ1Nguyen Van Hung
 
Khoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieuKhoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieuNguyen Van Hung
 
De cuong tu tuong hcm khoa iv
De cuong tu tuong hcm  khoa ivDe cuong tu tuong hcm  khoa iv
De cuong tu tuong hcm khoa ivNguyen Van Hung
 

More from Nguyen Van Hung (18)

Su dung linux shell
Su dung linux shellSu dung linux shell
Su dung linux shell
 
Cai dat va_cau_hinh_iptables
Cai dat va_cau_hinh_iptablesCai dat va_cau_hinh_iptables
Cai dat va_cau_hinh_iptables
 
Git slides
Git slidesGit slides
Git slides
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
So sánh asp.net và mvc
So sánh asp.net và mvcSo sánh asp.net và mvc
So sánh asp.net và mvc
 
Cong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatCong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhat
 
Cong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhatCong thuc sinh hoc 12 day du nhat
Cong thuc sinh hoc 12 day du nhat
 
Asp net mvc3 music store egroups vn
Asp net mvc3 music store   egroups vnAsp net mvc3 music store   egroups vn
Asp net mvc3 music store egroups vn
 
Asp.net mvc 3 (c#) (9 tutorials) egroups vn
Asp.net mvc 3 (c#) (9 tutorials)   egroups vnAsp.net mvc 3 (c#) (9 tutorials)   egroups vn
Asp.net mvc 3 (c#) (9 tutorials) egroups vn
 
Northwind products
Northwind productsNorthwind products
Northwind products
 
Cau truc dl_va_giai_thuat_bai1[1] - copy
Cau truc dl_va_giai_thuat_bai1[1] - copyCau truc dl_va_giai_thuat_bai1[1] - copy
Cau truc dl_va_giai_thuat_bai1[1] - copy
 
Bao cao
Bao caoBao cao
Bao cao
 
Thạch quyển và các dạng địa hình
Thạch quyển và các dạng địa hìnhThạch quyển và các dạng địa hình
Thạch quyển và các dạng địa hình
 
Bài tập về chuẩn hóa chuỗ1
Bài tập về chuẩn hóa chuỗ1Bài tập về chuẩn hóa chuỗ1
Bài tập về chuẩn hóa chuỗ1
 
Khoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieuKhoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieu
 
Doi xung mang mot chieu
Doi xung mang mot chieuDoi xung mang mot chieu
Doi xung mang mot chieu
 
Gtrinh oop[1]
Gtrinh oop[1]Gtrinh oop[1]
Gtrinh oop[1]
 
De cuong tu tuong hcm khoa iv
De cuong tu tuong hcm  khoa ivDe cuong tu tuong hcm  khoa iv
De cuong tu tuong hcm khoa iv
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Recently uploaded (20)

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Introduction to git

  • 1. Introduction To GIT Rob Di Marco Philly Linux Users Group July 14, 2008
  • 2. A Brief History of Git • Linus uses BitKeeper to manage Linux code • Ran into BitKeeper licensing issue  Liked functionality  Looked at CVS as how not to do things • April 5, 2005 - Linus sends out email showing first version • June 15, 2005 - Git used for Linux version control
  • 3. Git is Not an SCM Never mind merging. It's not an SCM, it's a distribution and archival mechanism. I bet you could make a reasonable SCM on top of it, though. Another way of looking at it is to say that it's really a content-addressable filesystem, used to track directory trees. Linus Torvalds, 7 Apr 2005 http://lkml.org/lkml/2005/4/8/9
  • 4. Centralized Version Control • Traditional version control system  Server with database  Clients have a working version • Examples  CVS  Subversion  Visual Source Safe • Challenges  Multi-developer conflicts  Client/server communication
  • 5. Distributed Version Control • Authoritative server by convention only • Every working checkout is a repository • Get version control even when detached • Backups are trivial • Other distributed systems include  Mercurial  BitKeeper  Darcs  Bazaar
  • 6. Git Advantages • Resilience  No one repository has more data than any other • Speed  Very fast operations compared to other VCS (I’m looking at you CVS and Subversion) • Space  Compression can be done across repository not just per file  Minimizes local size as well as push/pull data transfers • Simplicity  Object model is very simple • Large userbase with robust tools
  • 7. Some GIT Disadvantages • Definite learning curve, especially for those used to centralized systems  Can sometimes seem overwhelming to learn • Documentation mostly through man pages • Windows support can be an issue  Can use through Cygwin  Also have the msysgit project
  • 8. Git Architecture • Index  Stores information about current working directory and changes made to it • Object Database  Blobs (files) • Stored in .git/objects • Indexed by unique hash • All files are stored as blobs  Trees (directories)  Commits • One object for every commit • Contains hash of parent, name of author, time of commit, and hash of the current tree  Tags
  • 9. Some Commands • Getting a Repository  git init  git clone • Commits  git add  git commit • Getting information  git help  git status  git diff  git log  git show
  • 10. Our First Git Repository • mkdir first-git-repo && cd first- git-repo • git init  Creates the basic artifacts in the .git directory • echo “Hello World” > hello.txt • git add .  Adds content to the index  Index reflects the working version  Must be run prior to a commit • git commit -a -m ‘Check in number one’
  • 11. Key Git Files/Directories • ~/.gitconfig • .git  In top level of repository  Contains all objects, commits, configuration, for project  .git/config has project specific configurations • .gitignore  Stored in directory for ignoring
  • 12. Working With Git • echo “I love Git” >> hello.txt • git diff  Shows changes we have made • git status  Shows list of modified files • git add hello.txt • git diff  No changes shown as diff compares to the index • git diff HEAD  Now can see the changes in working version • git status • git commit -m ‘Second commit’
  • 13. Viewing What Has Changed • git log  Note the hash code for each commit. • git show <OBJECT>  Can use full or shortened hash • git reflog to see all changes that have occurred
  • 14. Git and Patch files • git diff HEAD^^  Show what has changed in last two commits • git diff HEAD~10..HEAD~2  Show what changed between 10 commits ago and two commits ago • git format-patch HEAD^^..HEAD  Will create individual patch files per commit • git apply to apply patches  git am to apply patches from an mbox • Can also compare  Between specific objects  To branches/tags
  • 15. Undoing What is Done • git checkout  Used to checkout a specific version/branch of the tree • git reset  Moves the tree back to a certain specified version  Use the --force to ignore working changes • git revert  Reverts a commit  Does not delete the commit object, just applies a patch  Reverts can themselves be reverted! • Git never deletes a commit object  It is very hard to shoot yourself in the foot!
  • 16. Git and Tagging • Tags are just human readable shortcuts for hashes • Branches can be made from any commit • git tag <tag-name>
  • 17. Branching • Git branching is lightweight  No massive copying a la CVS/Subversion  Tools for helping merge branches and changes easily • You are ALWAYS on a branch • Branches can be local or remote • Key commands  git branch  git merge  git cherry-pick • Allows you to choose specific commits to apply • You can edit the commits while cherry picking
  • 18. Using Branches • git checkout -b branch • git checkout -b devel/branch • git branch  Lists all local branches available • We can now make changes in one branch and propagate change using  git merge  git cherry-pick
  • 19. Rebasing Example • Simple branching o--o--o <-- origin a--b--c <-- mywork
  • 20. Rebasing Example • Work done on origin branch o--o--O--o--o--o <-- origin a--b--c <-- mywork
  • 21. Rebasing Example • Could merge changes into branch • git merge origin o--o--O--o--o--o <-- origin a--b--c--m<-- mywork
  • 22. Rebasing Example • Rebasing moves branch point • git rebase origin o--o--O--o--o--o <-- origin a`--b`--c`
  • 23. Cleaning Up • git fsck  Checks object database to make sure all is sane  Can show information about dangling objects • git gc  Cleans up repository and compress files  When used with --prune, cleans out dangling blobs  Can really speed up larger repositories
  • 24. Using Remote • Use git clone to replicate repository • Get changes with  git fetch (fetches and merges)  git pull • Propagate changes with  git push • Protocols  Local filesystem  SSH  Rsync  HTTP  Git protocol
  • 25. Cloning our Repository • git clone first-git-repo  Now have a full git repository to work with • Changes are pushed back with git push  Pushing changes WILL NOT change working copy on the repository being worked on • Branches can be based off of remote branches  git branch --track new-branch remote/branch • Remote configuration information stored in .git/config  Can have multiple remote backends!
  • 26. Git for Software Versioning • Create convention to define default server • Developers clone from central server • Lots of tools for transmitting patches between developers • Being used for  Linux (obviously)  Ruby On Rails  Check out http://github.com for a variety of hosted projects
  • 27. Git for Backups • Example: Directory needs regular backups  Could use rsync but unwieldy in size • Create Git repository for appropriate directory  Regular local commits  Regular push to backup location  Get simple revision heistory
  • 28. Git for Configuration Management • Example: Apache configurations  Multiple environments (dev/test/production)  Minor differences between environments • IP Address • Log levels  Want to effectively move changes across environments
  • 29. Git and Other VCS • Integrations with  Subversion  CVS  Darcs  Many others • Example of integration with Subversion  Use git-svn to fetch and commit push • Note initial fetch may take a long time as each commit is downloaded individually!  Use git commands for everything  Branches integrated with tags and branches
  • 30. Some Git Coolness • bash/zsh completion • Gitk  GUI to review changes • git instaweb  Used for starting HTTP process for browing project
  • 31. Further Resources • http://git.or.cz/  http://git.or.cz/course/cvs.html (For CVS users)  http://git.or.cz/course/svn.html (For SVN users) • http://www.kernel.org/pub/software/scm/git/docs/user • http://jonas.iki.fi/git_guides/HTML/git_guide/