SlideShare ist ein Scribd-Unternehmen logo
1 von 26
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)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Ähnlich wie Workshop on Source control, git merge walkthroughs

Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdfAliaaTarek5
 
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 customizationsIan Walls
 
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-DevelopersJohn Anderson
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-DevelopersAll Things Open
 
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 ArticlePRIYATHAMDARISI
 
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
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry 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_gitLuis Atencio
 
Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 

Ähnlich wie 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
 

Kürzlich hochgeladen

What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 

Kürzlich hochgeladen (20)

What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 

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.