SlideShare a Scribd company logo
1 of 33
@DivineOmega
By Jordan Hall
The Fundamentals of Git
@DivineOmega
Background
What, why, when?
@DivineOmega
What is Git?
● Version control
● Distributed
● Free (GNU GPL2)
@DivineOmega
History of Git
● Developed in 2005
– Started on 3 April
– 1.0 release on 21 December 2005
● Created
– For the Linux Kernel
– By Linus Torvalds
● Maintained by Junio Hamano
@DivineOmega
'Git'?
"I'm an egotistical bastard, and I name all my
projects after myself. First 'Linux', now 'git'."
Linus Torvalds
@DivineOmega
'Git'?
@DivineOmega
How people use Git
● Many different ways
● Can just be used locally
– Just on your PC
● Or between teams
– Using a remote repository
● Many web services/interfaces
– GitHub, GitLab, BitBucket, etc.
@DivineOmega
Git Internals
What makes up typical Git usage
@DivineOmega
The Git Places
● Working directory
● 'Stage' or 'Staging Area'
● Local Git repository
– '.git' directory
● Optionally, remote Git repository
– Known as 'remotes'
@DivineOmega
Working directory
● Where you work
● Where you make your changes
● Use 'git checkout' to revert changes to a file in
the working directory (back to the last commit)
● Sometimes called the 'workspace'
@DivineOmega
Staging area
● Any files about to be committed ('staged')
● Use 'git add' to move files to the staging area
('stage' them)
● Use 'git reset' to remove files from the staging area
● Stored in index file in your .git directory
● Sometimes called the 'index'
@DivineOmega
Local Git Repository
● All committed files, revision history, etc.
– Commits (objects identified by SHA1 hashes – commit IDs)
– Pointers to certain commits (known as references)
●
Branches
●
Tags
– 'Head' – where you currently are, a pointer to another reference
● Use 'git commit' to store any staged files in a new commit
● Use 'git revert' to undo a commit by its ID (creates a new commit)
●
Most of what is stored in your .git directory (.git/objects/ & .git/refs/)
@DivineOmega
Remote Git Repository
● Any repository not on your computer
● Known as a 'remote'
● Consists of a name and a URL
● 'git remote add', 'git remote remove', 'git remote'
● 'git push' to send changes to the remote
● 'git pull' to fetch & merge changes from the remote
@DivineOmega
Git Branches
Splitting off to do new things
@DivineOmega
Quick Explanation of Branches
● Just a named pointer to a specific commit
● Use 'git branch branch_name' to create one
pointing at your current commit
● File containing the SHA-1 hash of the commit it
points to
– .git/refs/heads/master
– .git/refs/heads/branch_name
@DivineOmega
Quick Explanation of Branches
http://goo.gl/wpesH6
● git branch testing
– Create new 'testing' branch at current commit
@DivineOmega
Quick Explanation of Branches
● Used to separate developments from the
'master' branch
– New features
– Phases of development
● Typically merged back into master when feature
is complete
@DivineOmega
Every Day Git Usage
Local and remote examples
@DivineOmega
Local Repository Example
http://goo.gl/4Pojzb
@DivineOmega
Local Repository Example
●
Assumption: A local Git repository exists and has multiple branches.
● git checkout greetings
– checkout 'greetings' branch of local repository
● create/change hello.txt in your favourite editor
● git add hello.txt
– stage files (added to the staging area / git index)
● git commit -m “Altered greeting”
– commit to local repository (.git directory)
@DivineOmega
Remote Repository Example
http://goo.gl/iCaOT
t
@DivineOmega
Remote Repository Example
●
Assumption: A remote Git repository exists and has been cloned locally.
● git add hello.txt
– stage files (to staging area / git index)
● git commit -m “New greets”
– commit to local repo. (.git directory)
● git push
– Updates the remote repository with local changes
– Technically:
● Tells the remote about your local branches/commits
● Asks the remote to update its branch reference (commit ID) to match the local reference
● It will oblige providing the change is a 'fast forward' (i.e. no merge required, just moving reference)
@DivineOmega
Merging
Bringing branches together
@DivineOmega
Create your new branch
● git branch super_new_feature
– Create a new branch for the new feature
● git checkout super_new_feature
– Switch to the new branch
@DivineOmega
Add your new fix/feature
● Add the new feature
– In our example, we'll say this feature only required a change to 'thing.php'
● git add thing.php
– Stage the file(s)
● git commit -m 'Added great new feature'
– Commit the file(s)
● Continue to change, add and commit until the feature is complete,
tested and ready to be merged into the main (master) branch
@DivineOmega
Merge the branch
● git checkout master
– Switch back to the main branch
● git merge super_new_feature
– Merge the changes from super_new_feature into the
current branch (master)
● git branch -d super_new_feature
– Delete the branch, to keep your local repository tidy
@DivineOmega
Notes on Merging and Conflicts
● Branches can be used however you wish.
● Master is nothing special, it's just the default.
● Automatic merges sometimes fail.
– CONFLICT (content): Merge conflict in thing.php
– Automatic merge failed; fix conflicts and then commit the result.
● When they do:
– Go into the files specified and fix the conflicts.
– Stages the files ('git add')
– Commit the fixes ('git commit') with an appropriate message
@DivineOmega
Git Directory and Commands
A quick overview
@DivineOmega
.git directory
@DivineOmega
Quick reference to Git commands
●
git status – Shows the current branch, modified working directory files, and staged files
●
git add – Stages files (gets them ready for committing)
● git commit – Moves all staged files into your local repository
●
git push – Sends all local repository changes to the remote, and updates the remote reference
●
git pull – Fetch and merge from a remote repository (or local branch)
● git revert – Undoes a commit based on its ID (creates a new commit)
●
git checkout – Reverts file(s) in the working directory back to the last commit (also be used to
switch branch)
– Be careful! This command can cause permanent loss of uncommitted changes!
● git reset – Removes files from the staging area (and more, be careful!)
– Danger Will Robinson! Use of the '--hard' parameter can cause permanent loss of both uncommitted and
committed changes!
@DivineOmega
Git Help
@DivineOmega
End!
Thanks. :)
@DivineOmega
References and useful links
● Explaining Git Push - http://goo.gl/VK2aiE
● About Git References - http://goo.gl/IwyJZZ
● The .git Directory - http://goo.gl/8vghFq
● Git Branching - http://goo.gl/oAbQDM
● Branching and Merging - http://goo.gl/lJkuUD
● Undoing Changes - http://goo.gl/VKpRhM
● The 'Master' Branch - http://goo.gl/NbECCY

More Related Content

What's hot (20)

Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git (実践入門編)
Git (実践入門編)Git (実践入門編)
Git (実践入門編)
 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentation
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow solo
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Learning git
Learning gitLearning git
Learning git
 
Git basics
Git basicsGit basics
Git basics
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Github basics
Github basicsGithub basics
Github basics
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Git
GitGit
Git
 
A prentation on github
A prentation on githubA prentation on github
A prentation on github
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 

Viewers also liked

Hybrid Publishing Lab - Scholarly Communication in the Digital Age
Hybrid Publishing Lab - Scholarly Communication in the Digital AgeHybrid Publishing Lab - Scholarly Communication in the Digital Age
Hybrid Publishing Lab - Scholarly Communication in the Digital AgeChristian Heise
 
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
 
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Arthur Doler
 
Getting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersGetting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersNoam Kfir
 
Gibbering about git - managing your source code made easy
Gibbering about git - managing your source code made easyGibbering about git - managing your source code made easy
Gibbering about git - managing your source code made easyMadeleine Schönemann
 
An Easy Explanation of UX (User Experience) By Think 360 Studio
An Easy Explanation of UX (User Experience) By Think 360 Studio An Easy Explanation of UX (User Experience) By Think 360 Studio
An Easy Explanation of UX (User Experience) By Think 360 Studio Think 360 Studio
 

Viewers also liked (11)

Hybrid Publishing Lab - Scholarly Communication in the Digital Age
Hybrid Publishing Lab - Scholarly Communication in the Digital AgeHybrid Publishing Lab - Scholarly Communication in the Digital Age
Hybrid Publishing Lab - Scholarly Communication in the Digital Age
 
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
 
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
 
Getting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS UsersGetting Started with Git: A Primer for SVN and TFS Users
Getting Started with Git: A Primer for SVN and TFS Users
 
#4 - Git - Stash
#4 - Git - Stash#4 - Git - Stash
#4 - Git - Stash
 
Git advanced
Git advancedGit advanced
Git advanced
 
GIT Fundamentals
GIT FundamentalsGIT Fundamentals
GIT Fundamentals
 
Gibbering about git - managing your source code made easy
Gibbering about git - managing your source code made easyGibbering about git - managing your source code made easy
Gibbering about git - managing your source code made easy
 
An Easy Explanation of UX (User Experience) By Think 360 Studio
An Easy Explanation of UX (User Experience) By Think 360 Studio An Easy Explanation of UX (User Experience) By Think 360 Studio
An Easy Explanation of UX (User Experience) By Think 360 Studio
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similar to The Fundamentals of Git

Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of GitWayne Chen
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016Peter Denev
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone useIkuru Kanuma
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primersaadulde
 

Similar to The Fundamentals of Git (20)

Git tech talk
Git tech talkGit tech talk
Git tech talk
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Git introduction
Git introductionGit introduction
Git introduction
 
Git basic
Git basicGit basic
Git basic
 
Git and github introduction
Git and github introductionGit and github introduction
Git and github introduction
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Introduction of Git
Introduction of GitIntroduction of Git
Introduction of Git
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone use
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Git training
Git trainingGit training
Git training
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Version control and GIT Primer
Version control and GIT PrimerVersion control and GIT Primer
Version control and GIT Primer
 

Recently uploaded

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

The Fundamentals of Git

  • 1. @DivineOmega By Jordan Hall The Fundamentals of Git
  • 3. @DivineOmega What is Git? ● Version control ● Distributed ● Free (GNU GPL2)
  • 4. @DivineOmega History of Git ● Developed in 2005 – Started on 3 April – 1.0 release on 21 December 2005 ● Created – For the Linux Kernel – By Linus Torvalds ● Maintained by Junio Hamano
  • 5. @DivineOmega 'Git'? "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'." Linus Torvalds
  • 7. @DivineOmega How people use Git ● Many different ways ● Can just be used locally – Just on your PC ● Or between teams – Using a remote repository ● Many web services/interfaces – GitHub, GitLab, BitBucket, etc.
  • 9. @DivineOmega The Git Places ● Working directory ● 'Stage' or 'Staging Area' ● Local Git repository – '.git' directory ● Optionally, remote Git repository – Known as 'remotes'
  • 10. @DivineOmega Working directory ● Where you work ● Where you make your changes ● Use 'git checkout' to revert changes to a file in the working directory (back to the last commit) ● Sometimes called the 'workspace'
  • 11. @DivineOmega Staging area ● Any files about to be committed ('staged') ● Use 'git add' to move files to the staging area ('stage' them) ● Use 'git reset' to remove files from the staging area ● Stored in index file in your .git directory ● Sometimes called the 'index'
  • 12. @DivineOmega Local Git Repository ● All committed files, revision history, etc. – Commits (objects identified by SHA1 hashes – commit IDs) – Pointers to certain commits (known as references) ● Branches ● Tags – 'Head' – where you currently are, a pointer to another reference ● Use 'git commit' to store any staged files in a new commit ● Use 'git revert' to undo a commit by its ID (creates a new commit) ● Most of what is stored in your .git directory (.git/objects/ & .git/refs/)
  • 13. @DivineOmega Remote Git Repository ● Any repository not on your computer ● Known as a 'remote' ● Consists of a name and a URL ● 'git remote add', 'git remote remove', 'git remote' ● 'git push' to send changes to the remote ● 'git pull' to fetch & merge changes from the remote
  • 15. @DivineOmega Quick Explanation of Branches ● Just a named pointer to a specific commit ● Use 'git branch branch_name' to create one pointing at your current commit ● File containing the SHA-1 hash of the commit it points to – .git/refs/heads/master – .git/refs/heads/branch_name
  • 16. @DivineOmega Quick Explanation of Branches http://goo.gl/wpesH6 ● git branch testing – Create new 'testing' branch at current commit
  • 17. @DivineOmega Quick Explanation of Branches ● Used to separate developments from the 'master' branch – New features – Phases of development ● Typically merged back into master when feature is complete
  • 18. @DivineOmega Every Day Git Usage Local and remote examples
  • 20. @DivineOmega Local Repository Example ● Assumption: A local Git repository exists and has multiple branches. ● git checkout greetings – checkout 'greetings' branch of local repository ● create/change hello.txt in your favourite editor ● git add hello.txt – stage files (added to the staging area / git index) ● git commit -m “Altered greeting” – commit to local repository (.git directory)
  • 22. @DivineOmega Remote Repository Example ● Assumption: A remote Git repository exists and has been cloned locally. ● git add hello.txt – stage files (to staging area / git index) ● git commit -m “New greets” – commit to local repo. (.git directory) ● git push – Updates the remote repository with local changes – Technically: ● Tells the remote about your local branches/commits ● Asks the remote to update its branch reference (commit ID) to match the local reference ● It will oblige providing the change is a 'fast forward' (i.e. no merge required, just moving reference)
  • 24. @DivineOmega Create your new branch ● git branch super_new_feature – Create a new branch for the new feature ● git checkout super_new_feature – Switch to the new branch
  • 25. @DivineOmega Add your new fix/feature ● Add the new feature – In our example, we'll say this feature only required a change to 'thing.php' ● git add thing.php – Stage the file(s) ● git commit -m 'Added great new feature' – Commit the file(s) ● Continue to change, add and commit until the feature is complete, tested and ready to be merged into the main (master) branch
  • 26. @DivineOmega Merge the branch ● git checkout master – Switch back to the main branch ● git merge super_new_feature – Merge the changes from super_new_feature into the current branch (master) ● git branch -d super_new_feature – Delete the branch, to keep your local repository tidy
  • 27. @DivineOmega Notes on Merging and Conflicts ● Branches can be used however you wish. ● Master is nothing special, it's just the default. ● Automatic merges sometimes fail. – CONFLICT (content): Merge conflict in thing.php – Automatic merge failed; fix conflicts and then commit the result. ● When they do: – Go into the files specified and fix the conflicts. – Stages the files ('git add') – Commit the fixes ('git commit') with an appropriate message
  • 28. @DivineOmega Git Directory and Commands A quick overview
  • 30. @DivineOmega Quick reference to Git commands ● git status – Shows the current branch, modified working directory files, and staged files ● git add – Stages files (gets them ready for committing) ● git commit – Moves all staged files into your local repository ● git push – Sends all local repository changes to the remote, and updates the remote reference ● git pull – Fetch and merge from a remote repository (or local branch) ● git revert – Undoes a commit based on its ID (creates a new commit) ● git checkout – Reverts file(s) in the working directory back to the last commit (also be used to switch branch) – Be careful! This command can cause permanent loss of uncommitted changes! ● git reset – Removes files from the staging area (and more, be careful!) – Danger Will Robinson! Use of the '--hard' parameter can cause permanent loss of both uncommitted and committed changes!
  • 33. @DivineOmega References and useful links ● Explaining Git Push - http://goo.gl/VK2aiE ● About Git References - http://goo.gl/IwyJZZ ● The .git Directory - http://goo.gl/8vghFq ● Git Branching - http://goo.gl/oAbQDM ● Branching and Merging - http://goo.gl/lJkuUD ● Undoing Changes - http://goo.gl/VKpRhM ● The 'Master' Branch - http://goo.gl/NbECCY