SlideShare a Scribd company logo
1 of 19
Download to read offline
An Introduction to Git
Disclaimer
My opinions are my own.
About Me
Jason Edgecombe (@edgester)
● Linux Administrator in the College of
Engineering at UNC Charlotte
● OpenAFS contributor & buildbot admin
● http://engrmosaic.uncc.edu
● https://github.com/edgester
● http://rampaginggeek.com
What is git?
● Distributed version control system
○ Version control system
■ Keeps snapshots of a set of folders and files
■ Let’s you go back in time to any snapshot
○ Distributed
■ All repositories are peers
■ Each repository has full history since last sync
■ Let’s you work without a network connection
■ Authority is determined by choice/convention
You should use git because...
● “cp” doesn’t scale (“cp file file.bak5.works”)
● allows for better metadata on snapshots
o description, timestamp, author, committer
● doesn’t clutter folders with copies
● space-efficient, only stores differences
● you don’t need a server to use it locally
Common Concepts
● commit - a snapshot in time
o referenced by SHA1 hash of contents
o links to all of its previous commits
o immutable/non-writable!
● branch - a writable variable that refers to a
commit
● tag - a read-only variable that refers to a
commit, with an optional message
Common Concepts, Part 2
● repository (a.k.a. “repo”) - A set of folders
that contains the git commit history,
optionally a working folder. Includes
branches & tags
● “remote” - “git remote” - a remote git repo
that is a peer of the current repo
● tracking branch - a local branch that is linked
to a remote branch
Concept Hierarchy
● repos contain remotes, branches, tags
● remotes link to tags, branches
● branches and tags refer to commits
● commits refer to files, folders,
parent commits
● repository→remote→branch/tag→commit
→files/folders
Common local commands
● Initialization
 git config --global user.name "John Doe"
 git config --global user.email jdoe@example.com
 git init
● Working with files
o Modify files - git add ; git rm ; git mv
● Snapshots
o Save - git commit
o Query - git log; git blame
o Discard changes - git reset; git checkout
Common Remote Commands
● Copy a remote repo
o git clone <url/address>
o git checkout origin/master
● Download changes
o git pull --rebase (fetch and rebase)
o git pull
o git fetch
● Upload changes
o git push
A Sample Project Workflow
1. “git init” / “git clone” # only once
2. “git checkout -b origin/master
3. “git pull --rebase” # before each session
4. #while working (loop frequently)
a. # edit files
b. “get add .” # to add new files!
c. “git commit .” # commit all modified files
5. “git push” # when work unit is done
6. # goto 2
Best Practices
● Jason’s guideline: use “git pull --rebase”
(fetch & rebase) workflow until proficient
● Don’t store code and configuration in the
same repo. (Use .gitignore files if needed)
● DO NOT STORE SECRETS in git!
○ Passwords, ssh keys, etc.
○ May be relaxed for encrypted secrets/isolated repo.
Cage Match: Git vs. Subversion
Git: Svn:
Full
history
in all
repos
Only
latest
checko
ut
Branchi
ng is
Branchi
ng is
Sources of Confusion
● No pre-defined source of truth for multi-repo
● Many workflows available, all are valid
● Deleted things (git rm) are still in the archive
● History not easily re-written
o “Removed” objects/commits can still persist
o History rewrites can be rejected in receiving repo
● Index (.git/) vs. working folder (./)
Git Clients
● Command-line - included in Linux distros
● GUI
o gitk - visualizer, included in distros
o IDE’s: Eclipse, Emacs, Vim
o TortoiseGit (Windows) - terminology mismatch!
 ‘reset’ and ‘revert’ don’t directly map to
command-line git behavior.
Demo Time
Git Hosting
● Github - https://github.com/
o Free and unlimited repos for open source projects
o Can pay for closed repos
o De facto standard for OSS project collaboration
● BitBucket - https://bitbucket.org/
o Free for a project with up to 5 collaborators
Self-Hosted Git
● Free
o Remote ssh server with a git repo
o Gitolite - http://gitolite.com/
o Gitlab CE
● Non-free
o Gitlab - https://about.gitlab.com/
o Atlassian Stash -
https://www.atlassian.com/software/stash
More Reading
● “man git-<command>”
o man git-commit
● Git web site
o https://git-scm.com/
● Pro Git book
o https://git-scm.com/book

More Related Content

What's hot

Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of troubleJon Senchyna
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleGaurav Kumar Garg
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG AntwerpKrimson
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitJuanma Orta
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgitGeshan Manandhar
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentalsNaincy Gupta
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started PresentationNap Ramirez
 
Gulp presentation
Gulp presentationGulp presentation
Gulp presentationmclise
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with GitDmitry Sheiko
 

What's hot (20)

Git advanced
Git advancedGit advanced
Git advanced
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git 101
Git 101Git 101
Git 101
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Basic Git
Basic GitBasic Git
Basic Git
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
 
Git basics
Git basicsGit basics
Git basics
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
Gulp presentation
Gulp presentationGulp presentation
Gulp presentation
 
Git 101
Git 101Git 101
Git 101
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
 

Viewers also liked

Viewers also liked (11)

CV
CVCV
CV
 
Sayings of the teacher of rightousness
Sayings of the teacher of rightousnessSayings of the teacher of rightousness
Sayings of the teacher of rightousness
 
My professional portfolio
My professional portfolioMy professional portfolio
My professional portfolio
 
Plan 3.
Plan 3.Plan 3.
Plan 3.
 
Presentación de paulo
Presentación de pauloPresentación de paulo
Presentación de paulo
 
Taller general de enteros mat 7
Taller general de enteros mat 7 Taller general de enteros mat 7
Taller general de enteros mat 7
 
Evolution of the Advertising Agency Business
Evolution of the Advertising Agency BusinessEvolution of the Advertising Agency Business
Evolution of the Advertising Agency Business
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
2015 IFFL Rules
2015 IFFL Rules2015 IFFL Rules
2015 IFFL Rules
 
Inspecciones de seguridad
Inspecciones de seguridadInspecciones de seguridad
Inspecciones de seguridad
 
Sysdig Monitorama Slides
Sysdig Monitorama SlidesSysdig Monitorama Slides
Sysdig Monitorama Slides
 

Similar to SouthEast LinuxFest 2015 - intro to git

The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of GitDivineOmega
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanJames Ford
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitAmit Mathur
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!Cory Webb
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone useIkuru Kanuma
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primersaadulde
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsGR8Conf
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
 

Similar to SouthEast LinuxFest 2015 - intro to git (20)

01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Command line git
Command line gitCommand line git
Command line git
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git hub
Git hubGit hub
Git hub
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone use
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Gitlikeapro 2019
Gitlikeapro 2019Gitlikeapro 2019
Gitlikeapro 2019
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 

Recently uploaded

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

Recently uploaded (20)

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

SouthEast LinuxFest 2015 - intro to git

  • 3. About Me Jason Edgecombe (@edgester) ● Linux Administrator in the College of Engineering at UNC Charlotte ● OpenAFS contributor & buildbot admin ● http://engrmosaic.uncc.edu ● https://github.com/edgester ● http://rampaginggeek.com
  • 4. What is git? ● Distributed version control system ○ Version control system ■ Keeps snapshots of a set of folders and files ■ Let’s you go back in time to any snapshot ○ Distributed ■ All repositories are peers ■ Each repository has full history since last sync ■ Let’s you work without a network connection ■ Authority is determined by choice/convention
  • 5. You should use git because... ● “cp” doesn’t scale (“cp file file.bak5.works”) ● allows for better metadata on snapshots o description, timestamp, author, committer ● doesn’t clutter folders with copies ● space-efficient, only stores differences ● you don’t need a server to use it locally
  • 6. Common Concepts ● commit - a snapshot in time o referenced by SHA1 hash of contents o links to all of its previous commits o immutable/non-writable! ● branch - a writable variable that refers to a commit ● tag - a read-only variable that refers to a commit, with an optional message
  • 7. Common Concepts, Part 2 ● repository (a.k.a. “repo”) - A set of folders that contains the git commit history, optionally a working folder. Includes branches & tags ● “remote” - “git remote” - a remote git repo that is a peer of the current repo ● tracking branch - a local branch that is linked to a remote branch
  • 8. Concept Hierarchy ● repos contain remotes, branches, tags ● remotes link to tags, branches ● branches and tags refer to commits ● commits refer to files, folders, parent commits ● repository→remote→branch/tag→commit →files/folders
  • 9. Common local commands ● Initialization  git config --global user.name "John Doe"  git config --global user.email jdoe@example.com  git init ● Working with files o Modify files - git add ; git rm ; git mv ● Snapshots o Save - git commit o Query - git log; git blame o Discard changes - git reset; git checkout
  • 10. Common Remote Commands ● Copy a remote repo o git clone <url/address> o git checkout origin/master ● Download changes o git pull --rebase (fetch and rebase) o git pull o git fetch ● Upload changes o git push
  • 11. A Sample Project Workflow 1. “git init” / “git clone” # only once 2. “git checkout -b origin/master 3. “git pull --rebase” # before each session 4. #while working (loop frequently) a. # edit files b. “get add .” # to add new files! c. “git commit .” # commit all modified files 5. “git push” # when work unit is done 6. # goto 2
  • 12. Best Practices ● Jason’s guideline: use “git pull --rebase” (fetch & rebase) workflow until proficient ● Don’t store code and configuration in the same repo. (Use .gitignore files if needed) ● DO NOT STORE SECRETS in git! ○ Passwords, ssh keys, etc. ○ May be relaxed for encrypted secrets/isolated repo.
  • 13. Cage Match: Git vs. Subversion Git: Svn: Full history in all repos Only latest checko ut Branchi ng is Branchi ng is
  • 14. Sources of Confusion ● No pre-defined source of truth for multi-repo ● Many workflows available, all are valid ● Deleted things (git rm) are still in the archive ● History not easily re-written o “Removed” objects/commits can still persist o History rewrites can be rejected in receiving repo ● Index (.git/) vs. working folder (./)
  • 15. Git Clients ● Command-line - included in Linux distros ● GUI o gitk - visualizer, included in distros o IDE’s: Eclipse, Emacs, Vim o TortoiseGit (Windows) - terminology mismatch!  ‘reset’ and ‘revert’ don’t directly map to command-line git behavior.
  • 17. Git Hosting ● Github - https://github.com/ o Free and unlimited repos for open source projects o Can pay for closed repos o De facto standard for OSS project collaboration ● BitBucket - https://bitbucket.org/ o Free for a project with up to 5 collaborators
  • 18. Self-Hosted Git ● Free o Remote ssh server with a git repo o Gitolite - http://gitolite.com/ o Gitlab CE ● Non-free o Gitlab - https://about.gitlab.com/ o Atlassian Stash - https://www.atlassian.com/software/stash
  • 19. More Reading ● “man git-<command>” o man git-commit ● Git web site o https://git-scm.com/ ● Pro Git book o https://git-scm.com/book