SlideShare une entreprise Scribd logo
1  sur  44
Git Acquainted
An introduction to version control with Git
Tyler Hunt
  @tylerhunt
homegrown apps
−−− git
+++
Version Control
index.html.bak.4
History
Collaboration
Basic Concepts
Repository
Branch
History
RCS & CVS
   Mid 80s
Subversion
  Early Aughts
Git
Mid Aughts
Open Source
Distributed
Redundant
Non-linear
Basics
> mkdir project

> cd project

> git init
Initialized empty Git repository in /project/.git/
> touch README

> git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
#
 README
nothing added to commit but untracked files present (use "git add" to
track)
> git add README

> git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
#
 new file: README
#
> git commit -m ‘Added file for documentation.’
[master (root-commit) 63b94ad] Added file for documentation.
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README

> git status
# On branch master
nothing to commit (working directory clean)
> echo ‘Documentation’ > README

> git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
#
 modified: README
#
no changes added to commit (use "git add" and/or "git commit -a")

> git diff README
diff --git a/README b/README
index e69de29..c3f01bd 100644
--- a/README
+++ b/README
@@ -0,0 +1 @@
+Documentation

> git commit -m 'Updated documentation.'
[master a382e49] Updated documentation.
 1 files changed, 1 insertions(+), 0 deletions(-)
Branching
> git branch
* master

> git checkout -b documentation
Switched to a new branch "documentation"

> git branch
* documentation
 master

> git checkout master
Switched to branch "master"

> git branch
 documentation
* master
> git checkout documentation
Switched to branch "documentation"

> echo ‘More Documentation’ >> README

> git commit README -m ‘Wrote more documentation.’
[documentation fbe3fdd] Wrote more documentation.
 1 files changed, 1 insertions(+), 0 deletions(-)

> git checkout master
Switched to branch "master"

> git merge documentation
Updating a382e49..fbe3fdd
Fast forward
 README | 1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
> git log
commit fbe3fdd6c09f2de540866108348bb33b7ee6b620
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 23:30:32 2009 -0500

  Wrote more documentation.

commit a382e49c9dadaff6b65a948a7736367391a0c625
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 23:29:17 2009 -0500

  Updated documentation.

commit 63b94ad5c0c035d915370b5101af22bc1270b5a9
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 00:23:20 2009 -0500

  Added file for documentation.
> cat README | sed -e 's/More/Less/' > README

> git commit README -m ‘Less is more.’
[master 80e7a3b] Less is more.
 1 files changed, 1 insertions(+), 1 deletions(-)

> git checkout documentation
Switched to branch "documentation"

> cat README | sed -e 's/More/More and More/' > README

> git commit README -m ‘More is more.’
[documentation ed8b839] More is more.
 1 files changed, 1 insertions(+), 1 deletions(-)

> git checkout master
Switched to branch "master"

> git merge documentation
Auto-merging README
CONFLICT (content): Merge conflict in README
Automatic merge failed; fix conflicts and then commit the result.
> git stat
README: needs merge
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
#
 unmerged: README
#
no changes added to commit (use "git add" and/or "git commit -a")

> cat README
Documentation
<<<<<<< HEAD:README
Less Documentation
=======
More and More Documentation
>>>>>>> documentation:README

> vi README
> git add README

> git commit
[master 29c758b] Merge branch 'documentation'
> git log
commit 29c758b5e64b5a7c4a8ecc1776e1a124236c6257
Merge: 80e7a3b ed8b839
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 23:46:08 2009 -0500

  Merge branch 'documentation'

  Conflicts:
    README

commit ed8b83965b9b089c6a354c40883c602d288a6e4a
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 23:42:56 2009 -0500

  More is more.

commit 80e7a3b3ccc3e0714e8ab9108e3d3ac3a1e175bb
Author: Tyler Hunt <tyler@tylerhunt.com>
Date: Wed Dec 2 23:42:01 2009 -0500

  Less is more.
Collaborating
> git remote add origin git@github.com:tylerhunt/project.git

> git push origin master
Counting objects: 18, done.
Delta compression using 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (18/18), 1.38 KiB, done.
Total 18 (delta 1), reused 0 (delta 0)
To git@github.com:tylerhunt/project.git
 * [new branch]      master -> master
> git clone git://github.com/tylerhunt/relax.git
Initialized empty Git repository in /project/.git/
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 18 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (1/1), done.
Tips
~/.gitconfig
.gitignore
Tags
Questions

Contenu connexe

Tendances

Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer CheatsheetAbdul Basit
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Git tutorial undoing changes
Git tutorial   undoing changesGit tutorial   undoing changes
Git tutorial undoing changesLearningTech
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheetLam Hoang
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control SystemMohammad Imam Hossain
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017Katie Sylor-Miller
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03Gourav Varma
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
 

Tendances (20)

Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
git - the basics
git - the basicsgit - the basics
git - the basics
 
Git
GitGit
Git
 
Git tutorial undoing changes
Git tutorial   undoing changesGit tutorial   undoing changes
Git tutorial undoing changes
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
An Introduction to Git
An Introduction to GitAn Introduction to Git
An Introduction to Git
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
Git learning
Git learningGit learning
Git learning
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Git basic commands
Git basic commandsGit basic commands
Git basic commands
 

En vedette

MachinEVO Presentation at VWBPE 2012
MachinEVO Presentation at VWBPE 2012MachinEVO Presentation at VWBPE 2012
MachinEVO Presentation at VWBPE 2012Heike Philp
 
Virtual Language Travel
Virtual Language TravelVirtual Language Travel
Virtual Language TravelHeike Philp
 
EU funded AVALON
EU funded AVALONEU funded AVALON
EU funded AVALONHeike Philp
 
Online conference as a learning resource for language educator
Online conference as a learning resource for language educatorOnline conference as a learning resource for language educator
Online conference as a learning resource for language educatorHeike Philp
 
Language Learning in Real-Time
Language Learning in Real-TimeLanguage Learning in Real-Time
Language Learning in Real-TimeHeike Philp
 
The AVALON project (Ignite presentation)
The AVALON project (Ignite presentation)The AVALON project (Ignite presentation)
The AVALON project (Ignite presentation)Heike Philp
 

En vedette (6)

MachinEVO Presentation at VWBPE 2012
MachinEVO Presentation at VWBPE 2012MachinEVO Presentation at VWBPE 2012
MachinEVO Presentation at VWBPE 2012
 
Virtual Language Travel
Virtual Language TravelVirtual Language Travel
Virtual Language Travel
 
EU funded AVALON
EU funded AVALONEU funded AVALON
EU funded AVALON
 
Online conference as a learning resource for language educator
Online conference as a learning resource for language educatorOnline conference as a learning resource for language educator
Online conference as a learning resource for language educator
 
Language Learning in Real-Time
Language Learning in Real-TimeLanguage Learning in Real-Time
Language Learning in Real-Time
 
The AVALON project (Ignite presentation)
The AVALON project (Ignite presentation)The AVALON project (Ignite presentation)
The AVALON project (Ignite presentation)
 

Similaire à Git Acquainted

Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git TogetherRakesh Jha
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Git with the flow
Git with the flowGit with the flow
Git with the flowDana White
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfmurad khan
 
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
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityRaja Soundaramourty
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 

Similaire à Git Acquainted (20)

Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Lets Git Together
Lets Git TogetherLets Git Together
Lets Git Together
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Git commands
Git commandsGit commands
Git commands
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Git_real_slides
Git_real_slidesGit_real_slides
Git_real_slides
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git
GitGit
Git
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git slides
Git slidesGit slides
Git slides
 

Dernier

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Dernier (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Git Acquainted

  • 1. Git Acquainted An introduction to version control with Git
  • 2. Tyler Hunt @tylerhunt
  • 13. RCS & CVS Mid 80s
  • 21. > mkdir project > cd project > git init Initialized empty Git repository in /project/.git/
  • 22. > touch README > git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)
  • 23. > git add README > git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README #
  • 24. > git commit -m ‘Added file for documentation.’ [master (root-commit) 63b94ad] Added file for documentation. 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README > git status # On branch master nothing to commit (working directory clean)
  • 25. > echo ‘Documentation’ > README > git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README # no changes added to commit (use "git add" and/or "git commit -a") > git diff README diff --git a/README b/README index e69de29..c3f01bd 100644 --- a/README +++ b/README @@ -0,0 +1 @@ +Documentation > git commit -m 'Updated documentation.' [master a382e49] Updated documentation. 1 files changed, 1 insertions(+), 0 deletions(-)
  • 27. > git branch * master > git checkout -b documentation Switched to a new branch "documentation" > git branch * documentation master > git checkout master Switched to branch "master" > git branch documentation * master
  • 28. > git checkout documentation Switched to branch "documentation" > echo ‘More Documentation’ >> README > git commit README -m ‘Wrote more documentation.’ [documentation fbe3fdd] Wrote more documentation. 1 files changed, 1 insertions(+), 0 deletions(-) > git checkout master Switched to branch "master" > git merge documentation Updating a382e49..fbe3fdd Fast forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 29. > git log commit fbe3fdd6c09f2de540866108348bb33b7ee6b620 Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 23:30:32 2009 -0500 Wrote more documentation. commit a382e49c9dadaff6b65a948a7736367391a0c625 Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 23:29:17 2009 -0500 Updated documentation. commit 63b94ad5c0c035d915370b5101af22bc1270b5a9 Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 00:23:20 2009 -0500 Added file for documentation.
  • 30. > cat README | sed -e 's/More/Less/' > README > git commit README -m ‘Less is more.’ [master 80e7a3b] Less is more. 1 files changed, 1 insertions(+), 1 deletions(-) > git checkout documentation Switched to branch "documentation" > cat README | sed -e 's/More/More and More/' > README > git commit README -m ‘More is more.’ [documentation ed8b839] More is more. 1 files changed, 1 insertions(+), 1 deletions(-) > git checkout master Switched to branch "master" > git merge documentation Auto-merging README CONFLICT (content): Merge conflict in README Automatic merge failed; fix conflicts and then commit the result.
  • 31. > git stat README: needs merge # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # unmerged: README # no changes added to commit (use "git add" and/or "git commit -a") > cat README Documentation <<<<<<< HEAD:README Less Documentation ======= More and More Documentation >>>>>>> documentation:README > vi README
  • 32. > git add README > git commit [master 29c758b] Merge branch 'documentation'
  • 33. > git log commit 29c758b5e64b5a7c4a8ecc1776e1a124236c6257 Merge: 80e7a3b ed8b839 Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 23:46:08 2009 -0500 Merge branch 'documentation' Conflicts: README commit ed8b83965b9b089c6a354c40883c602d288a6e4a Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 23:42:56 2009 -0500 More is more. commit 80e7a3b3ccc3e0714e8ab9108e3d3ac3a1e175bb Author: Tyler Hunt <tyler@tylerhunt.com> Date: Wed Dec 2 23:42:01 2009 -0500 Less is more.
  • 35.
  • 36.
  • 37. > git remote add origin git@github.com:tylerhunt/project.git > git push origin master Counting objects: 18, done. Delta compression using 2 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (18/18), 1.38 KiB, done. Total 18 (delta 1), reused 0 (delta 0) To git@github.com:tylerhunt/project.git * [new branch] master -> master
  • 38. > git clone git://github.com/tylerhunt/relax.git Initialized empty Git repository in /project/.git/ remote: Counting objects: 18, done. remote: Compressing objects: 100% (6/6), done. remote: Total 18 (delta 1), reused 0 (delta 0) Receiving objects: 100% (18/18), done. Resolving deltas: 100% (1/1), done.
  • 39.
  • 40. Tips
  • 43. Tags

Notes de l'éditeur

  1. My hope tonight is to give you an introduction to version control with Git.
  2. I&amp;#x2019;m Tyler Hunt, and @tylerhunt on Twitter.
  3. I have a little blog and software company called Devoh.
  4. Before we jump into talking about git, I want to first take a step back.
  5. I want to start off talking a bit about version control. Why is it important? Why should you use it?
  6. So you don&amp;#x2019;t have to have files like this lying around.
  7. It keeps a history of all of the changes ever made to your files. If you need to revert back to an old version, or figure out why something was changed, the history is always there for you.
  8. And if you&amp;#x2019;re working in a team, even if it&amp;#x2019;s just two people, version control is a must. It&amp;#x2019;s the best way to synchronize your development efforts. It&amp;#x2019;s also a great way to keep an audit trail of who made which changes.
  9. A repository is a complete collection of all of the files in a project and their full version history.
  10. A branch is a way to duplicate the resources in a repository to allow parallel modifications to be made. This lets you start on a feature, and then switch branches to work on something else. Also, used to maintain separate development and production branches.
  11. RCS, Revision Control System, was an early attempt at version control that only worked with individual files. CVS, Concurrent Versions System, was originally devised as a set of scripts on top of RCS to allow multiple files to be managed.
  12. Subversion was designed as a mostly-compatible replacement for CVS. It fixed some of the limitations of CVS, like it&amp;#x2019;s lack of knowledge about directories.
  13. Git was created by Linus Torvalds as a replacement for BitKeeper, which was the version control software used for the Linux kernel at the time.
  14. The reason Linus even thought about creating a new version control system was over a licensing change with BitKeeper that meant it was no longer free for kernel developers to use. An open source solution prevents this from happening.
  15. Git&amp;#x2019;s biggest advantages over Subversion is its distributed nature. With Git, there&amp;#x2019;s no longer a single master repository, but all repositories are equal.
  16. Without a centralized repository, there&amp;#x2019;s an implicit layer of redundancy. If the repository on the server is corrupted, you can simple copy up your local repository.
  17. Git was designed to be fast for non-linear development styles. It makes it trivial to create and change branches.
  18. Let&amp;#x2019;s jump in now and show how its used. I&amp;#x2019;m not going to cover installation since it varies depending on your platform.
  19. First, we&amp;#x2019;ll make a new directory for our project. Then we&amp;#x2019;ll switch to that directory and initialize a new repository there. This creates a .git directory inside our project where all of the metadata will be stored.
  20. Here we create a new file, and then check the status of our repository. The output of `git status` shows that there&amp;#x2019;s one &amp;#x201C;untracked&amp;#x201D; file. It also tells us how we can start tracking that file.
  21. Here, we&amp;#x2019;ve added the file to the repository, and then checked its status again. The file has been added to what&amp;#x2019;s called the &amp;#x201C;index.&amp;#x201D; This is like a staging area for commits. Now that the file has been added, we can do the actual commit.
  22. Here we commit the contents of the index using a command line argument for the commit message. Leave off the message will open an editor where you can write your message. Now our working directory is clean, meaning all of our changes have been committed.
  23. We we make changes, git will let us know which files have been modified. Doing a `git diff` shows the modifications that have been made since the last commit. It&amp;#x2019;s a good idea to review your changes before adding and committing.
  24. Now let&amp;#x2019;s take a look at branching and merging. Branches are a way to isolate the changes you&amp;#x2019;re making from the rest of the project. It&amp;#x2019;s a good practice to create a branch for each new task.
  25. `git branch` show us all of the local branches in our repository. `git checkout -b` will create a new branch and switch to it. `git checkout` will switch branches.
  26. Now let&amp;#x2019;s switch back to our documentation branch and write some more documentation. Then we&amp;#x2019;ll commit our changes. Next, we&amp;#x2019;ll switch back to master and merge them in. Normally you wouldn&amp;#x2019;t do the merge until the code is complete, tested, and ready to deploy.
  27. `git log` will show us the history of all of our commits on the current branch. As you can see here, the commit from our documentation branch is now on master. Merging is like copying all of the new commits from one branch into another.
  28. GitHub is a social network for coding. It&amp;#x2019;s a web service providing hosted git repositories, with a focus on ease of collaboration.
  29. We&amp;#x2019;re going to use GitHub to create a new repository for our project. You can create as many public repositories as you like for free.
  30. Once the repository has been created, you&amp;#x2019;ll get a screenful of instructions. Here are the steps they give for pushing your local repository up for the first time. Remotes are simply non-local repositories. Pushing to a remote syncs it up with your local.
  31. Once you&amp;#x2019;ve pushed the code up to GitHub, it&amp;#x2019;s easy for anyone else to work with it. `git clone` is used to make a local copy of a remote repository. Here, we&amp;#x2019;re cloning our newly created GitHub repository using it&amp;#x2019;s public clone URL.
  32. The social power of GitHub is really manifested in the fork feature. This creates a clone of someone else&amp;#x2019;s repository under your own account. You can then work on it, push up your changes, and then submit a &amp;#x201C;pull request.&amp;#x201D;
  33. This is where you&amp;#x2019;ll set up the name and email address that identifies you as a comitter. GitHub will also use this to identify match up your commits with your GitHub account. You can also create aliases here for git commands, like &amp;#x201C;stat&amp;#x201D; for &amp;#x201C;status.&amp;#x201D; Helpful for SVN.
  34. Each repository can have a .gitignore file in its root. This file specifies paths and file names that you want to leave out of the repository. Temporary files and configuration files containing authentication credentials.
  35. You can also tag specific commits in your repository. This is useful for marking a commit as a release of a new version of your application. It might also be used to mark when your repository was last deployed.