SlideShare a Scribd company logo
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/
Ad

More Related Content

What's hot (20)

Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
Legal Services National Technology Assistance Project (LSNTAP)
 
Github
GithubGithub
Github
MeetPatel710
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
Shawn Doyle
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
atishgoswami
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
Naim Latifi
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
MohanRaviRohitth
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
Md. Main Uddin Rony
 
Git vs. Mercurial
Git vs. MercurialGit vs. Mercurial
Git vs. Mercurial
Marian Marinov
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
Yash
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
Naveen Pandey
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hü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 Users
Noam Kfir
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
Medhat Dawoud
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
TingYen Lee
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Randal Schwartz
 
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
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
Shawn Doyle
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
atishgoswami
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
Naim Latifi
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
Yash
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
Naveen Pandey
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
Hü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 Users
Noam Kfir
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
Medhat 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
 

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
Kim Moir
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
Betclic Everest Group Tech Team
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat 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 levels
Gorav Singal
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Aidan Casey
 
Git
GitGit
Git
Okba Mahdjoub
 
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 Git
Robert 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 Git
Geoff Hoffman
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
Eshaan35
 
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 stars
Strannik_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 Rousselt
NCCOMMS
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
Haitham Raik
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Fundamentals and basics of Git and commands
Fundamentals and basics of Git and commandsFundamentals and basics of Git and commands
Fundamentals and basics of Git and commands
DivyanshGupta922023
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
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
Kim Moir
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat 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 levels
Gorav Singal
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Aidan 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 Git
Robert 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 Git
Geoff Hoffman
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
Eshaan35
 
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 stars
Strannik_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 Rousselt
NCCOMMS
 
Fundamentals and basics of Git and commands
Fundamentals and basics of Git and commandsFundamentals and basics of Git and commands
Fundamentals and basics of Git and commands
DivyanshGupta922023
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Ad

More from Nguyen Van Hung (18)

Su dung linux shell
Su dung linux shellSu dung linux shell
Su dung linux shell
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_iptables
Nguyen Van Hung
 
Git slides
Git slidesGit slides
Git slides
Nguyen Van Hung
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen 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à mvc
Nguyen 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 nhat
Nguyen 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 nhat
Nguyen 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 vn
Nguyen 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 vn
Nguyen Van Hung
 
Northwind products
Northwind productsNorthwind products
Northwind products
Nguyen 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] - copy
Nguyen 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ình
Nguyen 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ỗ1
Nguyen Van Hung
 
Khoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieuKhoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieu
Nguyen Van Hung
 
Doi xung mang mot chieu
Doi xung mang mot chieuDoi xung mang mot chieu
Doi xung mang mot chieu
Nguyen 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 iv
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_iptables
Nguyen 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à mvc
Nguyen 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 nhat
Nguyen 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 nhat
Nguyen 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 vn
Nguyen 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 vn
Nguyen 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] - copy
Nguyen 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ình
Nguyen 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ỗ1
Nguyen Van Hung
 
Khoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieuKhoahoctunhien.net mang1chieu
Khoahoctunhien.net mang1chieu
Nguyen 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 iv
Nguyen Van Hung
 
Ad

Recently uploaded (20)

Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 

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/