SlideShare a Scribd company logo
SOURCE CONTROL
15 years ago... blog of the guy who would go
onto co-found Stack Overflow
l1. Do you use source control?
l...if you don't have source control, you're going to
stress out trying to get programmers to work
together. Programmers have no way to know what
other people did.
lMistakes can't be rolled back easily. The other
neat thing about source control systems is that the
source code itself is checked out on every
programmer's hard drive -- I've never heard of a
project using source control that lost a lot of code.
Many people's first introduction to the concept:
MS Word, Track changes - 2004
A history of source control
http://codicesoftware.blogspot.com/2010/11/version-control-timeline.html
Summary
lSource Control / Revision Control / Version
Control – tools used to help manage and track
changes in text files (ie source code)
lGit – a source control tool, written by Linus
Torvalds that we will be learning today
lGithub - A website, which makes it easy to work
collaboratively on git repositories. Bitbucket is
similar
Recap
lUse source control
lIt has been “best practices” for 15+ years
lUse source control
lEven if it's just you, use source control
3 things to help you understand Git
lHashing
lDiffs
lDirected Acyclic Graphs
Hashes
lConvert any-length strings into (shorter) fixed
sized strings.
lUseful for hash tables, cryptography, data
transmission and many other uses.
l$ echo "Hello world" | md5sum
lf0ef7081e1539ac00ef5b761b4fb01b3 -
Try:
lCopying files, hashing them.
lCreating files that are identical (not via copying),
hashing them
lModify files, hash them. Modify back.
lSee how it works?
Diff
lCreate a file with lots of lines
lMake a copy
lModify a line ½ way through
lRun diff file1.txt file2.txt
Directed Acyclic Graph
lDirected (ie the link is always the same direction,
ie between parent->child)
lAcyclic – no loops
lGraph – has nodes & edges
Install first...
Linux:
sudo apt-get install -y git meld
Git Hello World
git help
mkdir -p ~/localwork/git_tutorial
cd ~/localwork/git_tutorial
git init
(ls -l .git)
echo “Hello world” > hello.txt
git add hello.txt
git commit -m “initial commit”
Git Hello World
git log
Commit contains - Hash, date, message,
person/email.
(Modify hello.txt)
git add hello.txt
git diff # Shows what changed
git commit -m “modified”
git log
rm hello.txt
git diff
git checkout hello.txt # revert
cat hello.txt
git log
git checkout 851ae # Copy your 1
st
commit hash
cat hello.txt
git checkout master
cat hello.txt
Moving through time...
Branches (easy fast forward)
git branch feature
git checkout feature
(modify hello.txt)
git commit -a -m “modified in feature branch”
git log # has commit in feature branch
git checkout master
git log # doesn't have commit
git merge feature # Merge FROM feature into current (master)
Updating 219ddc3..70d4bfa
Fast-forward
hello.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
git branch
git branch -d feature # Delete feature
git log --graph
Branches (with auto merge)
(make hello.txt have lots of lines, and commit)
git branch feature
git checkout feature
(modify hello.txt on top lines)
git commit -a -m “modified in feature branch”
git checkout master
(Modify hello.txt on bottom lines)
git commit -a -m “modified in master”
git merge feature # auto-merges
git log --graph
Blame
Who did this??!
git blame hello.txt
Branches (with manual merge)
git branch my_branch
git checkout my_branch
(modify hello.txt)
git commit -a -m “modified in my_branch”
git checkout master
(Modify hello.txt on SAME lines)
git commit -a -m “modified in master”
git merge my_branch # can't do it
cat hello.txt
git mergetool # Visual tool to do it
git log --graph
Remote repositories
lClone
lPull
lPush
lIf a remote won't accept my push, 99% of the time
pull, merge, commit, push will fix it.
Git ecosystem
lGithub
lBitbucket
lSmartGit (GUI)

More Related Content

What's hot

Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
Otto Kekäläinen
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
Leonid Mamchenkov
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
Bruno Bossola
 
Git basics
Git basicsGit basics
Git basics
Amit Sawhney
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Colin Su
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
Bruno Bossola
 
Git basics
Git basicsGit basics
Git basics
Ashwin Date
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
Chris Aniszczyk
 
Knolx master-slides
Knolx master-slidesKnolx master-slides
Knolx master-slides
Mayank Bairagi
 
Demo
DemoDemo
git & GitHub workshop
git & GitHub workshopgit & GitHub workshop
git & GitHub workshop
Shubhendra Singh Chauhan
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
Anuj Sharma
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
Jon Senchyna
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
Krimson
 
Pragmatic Guide to Git
Pragmatic Guide to GitPragmatic Guide to Git
Pragmatic Guide to GitConFoo
 

What's hot (20)

Git advanced
Git advancedGit advanced
Git advanced
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
 
Git basics
Git basicsGit basics
Git basics
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Git basics
Git basicsGit basics
Git basics
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
 
Knolx master-slides
Knolx master-slidesKnolx master-slides
Knolx master-slides
 
Demo
DemoDemo
Demo
 
git & GitHub workshop
git & GitHub workshopgit & GitHub workshop
git & GitHub workshop
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
Pragmatic Guide to Git
Pragmatic Guide to GitPragmatic Guide to Git
Pragmatic Guide to Git
 

Similar to Workshop on Source control, git merge walkthroughs

Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
AliaaTarek5
 
Git 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsGit 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizations
Ian Walls
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?
Celestine Omin
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
John Anderson
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
All Things Open
 
3 Git
3 Git3 Git
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
KeerthanaJ32
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Git Basics
Git BasicsGit Basics
Git Basics
Ryan Condron
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)
chenghlee
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
Otto Kekäläinen
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
Alberto Leal
 
Git 101
Git 101Git 101
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
Dmitry Guyvoronsky
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_git
Luis Atencio
 
Git for developers
Git for developersGit for developers
Git for developers
Hacen Dadda
 

Similar to Workshop on Source control, git merge walkthroughs (20)

Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Git 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsGit 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizations
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
 
3 Git
3 Git3 Git
3 Git
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Git introduction
Git introductionGit introduction
Git introduction
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
 
Git hub
Git hubGit hub
Git hub
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git 101
Git 101Git 101
Git 101
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_git
 
Git for developers
Git for developersGit for developers
Git for developers
 

Recently uploaded

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 

Recently uploaded (20)

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 

Workshop on Source control, git merge walkthroughs

  • 2. 15 years ago... blog of the guy who would go onto co-found Stack Overflow
  • 3. l1. Do you use source control? l...if you don't have source control, you're going to stress out trying to get programmers to work together. Programmers have no way to know what other people did. lMistakes can't be rolled back easily. The other neat thing about source control systems is that the source code itself is checked out on every programmer's hard drive -- I've never heard of a project using source control that lost a lot of code.
  • 4. Many people's first introduction to the concept: MS Word, Track changes - 2004
  • 5. A history of source control http://codicesoftware.blogspot.com/2010/11/version-control-timeline.html
  • 6.
  • 7.
  • 8. Summary lSource Control / Revision Control / Version Control – tools used to help manage and track changes in text files (ie source code) lGit – a source control tool, written by Linus Torvalds that we will be learning today lGithub - A website, which makes it easy to work collaboratively on git repositories. Bitbucket is similar
  • 9. Recap lUse source control lIt has been “best practices” for 15+ years lUse source control lEven if it's just you, use source control
  • 10.
  • 11. 3 things to help you understand Git lHashing lDiffs lDirected Acyclic Graphs
  • 12. Hashes lConvert any-length strings into (shorter) fixed sized strings. lUseful for hash tables, cryptography, data transmission and many other uses. l$ echo "Hello world" | md5sum lf0ef7081e1539ac00ef5b761b4fb01b3 -
  • 13. Try: lCopying files, hashing them. lCreating files that are identical (not via copying), hashing them lModify files, hash them. Modify back. lSee how it works?
  • 14. Diff lCreate a file with lots of lines lMake a copy lModify a line ½ way through lRun diff file1.txt file2.txt
  • 15. Directed Acyclic Graph lDirected (ie the link is always the same direction, ie between parent->child) lAcyclic – no loops lGraph – has nodes & edges
  • 17. Git Hello World git help mkdir -p ~/localwork/git_tutorial cd ~/localwork/git_tutorial git init (ls -l .git) echo “Hello world” > hello.txt git add hello.txt git commit -m “initial commit”
  • 18. Git Hello World git log Commit contains - Hash, date, message, person/email.
  • 19. (Modify hello.txt) git add hello.txt git diff # Shows what changed git commit -m “modified” git log rm hello.txt git diff git checkout hello.txt # revert cat hello.txt
  • 20. git log git checkout 851ae # Copy your 1 st commit hash cat hello.txt git checkout master cat hello.txt Moving through time...
  • 21. Branches (easy fast forward) git branch feature git checkout feature (modify hello.txt) git commit -a -m “modified in feature branch” git log # has commit in feature branch git checkout master git log # doesn't have commit git merge feature # Merge FROM feature into current (master) Updating 219ddc3..70d4bfa Fast-forward hello.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) git branch git branch -d feature # Delete feature git log --graph
  • 22. Branches (with auto merge) (make hello.txt have lots of lines, and commit) git branch feature git checkout feature (modify hello.txt on top lines) git commit -a -m “modified in feature branch” git checkout master (Modify hello.txt on bottom lines) git commit -a -m “modified in master” git merge feature # auto-merges git log --graph
  • 23. Blame Who did this??! git blame hello.txt
  • 24. Branches (with manual merge) git branch my_branch git checkout my_branch (modify hello.txt) git commit -a -m “modified in my_branch” git checkout master (Modify hello.txt on SAME lines) git commit -a -m “modified in master” git merge my_branch # can't do it cat hello.txt git mergetool # Visual tool to do it git log --graph
  • 25. Remote repositories lClone lPull lPush lIf a remote won't accept my push, 99% of the time pull, merge, commit, push will fix it.