SlideShare a Scribd company logo
1 of 37
Git
• Created by Linus Torvalds
• April 2005
• Distributed version control system
• Open source and free software
• Faster, support all platform
• Safe guard against data corruption ….
Goal
• Git Installation
• Git Architecture
• Git Concept
• Add, commit, push, pull, stash, undo
• .gitignore
• tree-is
• Branching
• Merging
• Remote repository communication(team work concept)
Github
• Lunched 2008
• GitHub offers plans for both private repositories and free
accounts which are commonly used to host open-source
software projects. As of June 2018, GitHub reports having
over 28 million users and 57 million repositories (including
28 million public repositories.),
Distributed version control
• Different users (or teams of users) maintain their own
repositories, instead of working from a central repository
• Changes are stored as change sets.
• Git focus on change set encapsulating a change set as a
discrete unit and then those change sets can be exchange
between repository
• No single master repository, just many working copies
• Each with their own combination of change sets.
Who is the user?
• Anyone want to truck hi note
• Review history log changes
• View difference between two versions
• Retrieve old version
• Anyone need to share changes with the collaborators
• Anyone not afraid of command line tools
Install git
• Mac OS
• brew install git
• Ubuntu
• apt-get install git
• Fedora
• yum install git
• Windows
• https://git-scm.com/download/win
Git configuration
• System
• User
• Project
User
Main job
• Make changes
• add changes
• Commit the changes
Git Architecture
• Three tree architecture
• Add command add file staging index
Repository
Staging Index
Working
Commit
Add file
Pull
what is staging index?
• I have 5 file , I wanted to add 2 file, then I put 2 file in
staging index and commit 2 file. Still 3 file is left, not added
yet, also not commit yet, those are available in my working
tree, they never added in staging index, or remote server.
They are waiting for another commit.
What is SHA?
• When we change, git generate a check-sum code,
checksum is an algorithm that generate number from data.
• Git generate checksum using SHA-1 hash algorithm. This
algorithms produce 40 digit hex number.
• Goal of checksum: data didn’t change
• checksum->HASH->SHA-1
Data integrity
• Git sure that you cannot change what you have committed
, when you have reset any data your checksum must be
changed.
Checksum
Checksum snapshot
acc0145
Parent ffffac0
Author Cm
Message Fix bug
ffffac0
Parent Nill
Author Cm
Message
Initial
commit
33affg3
Parent acc0145
Author Cm
Message Fix bug
Snapshot 1 Snapshot 2 Snapshot 3
HEAD
• Head point to specific commit to the repository
• If you add new commit pointer have to change to new commit.
• Head point to “tip” current branch of the repository…
• Not staging index or working directory
• Last stage of repository what I checked out.
• Head pointer is the place where we start record.
• Head is the last commit of the current branch
• Head always checked currently check-out branch
HEAD
ffffac0 acc0145 33affg3
head
--amend
acc0145
Parent ffffac0
Author Cm
Message Fix bug
ffffac0
Parent Nill
Author Cm
Message
Initial
commit
33affg3
Parent acc0145
Author Cm
Message Fix bug
Snapshot 1 Snapshot 2 Snapshot 3
Git reset
• —soft
• Does not change staging index or working directory.
• It just move the pointer
• Keep code safe zone
• It move only pointer nothing else
• —mixed
• Change head pointer to specify commit
• Change staging index to patch repository
• Does not change working directory
• We don’t lost any data
• —hard
• Change staging index and working directory to match
• Any changes after this commit are completely deleted….
• Automatically garbage collection
Caution
• When you wanted to reset anything , copy last few
commits and pest int a text file.
.gitignore
• *.php
• *.dll
• .DS_Store
• log/*.log
• !index.php//dont ignore…..
• Ignore all file within directory directory/
• Comment lines begins with #
• Git does not truck empty directory
Compare
• Comparing the commit references , what actual stage of
all files in this repository at that point of time.
• It means what the changes over time…..
Branching
• Don’t causes lot of headaches
• Don’t take lot of processing power
• Easy to created also easy to deleted
• Try new ideas
• Isolate features
• Context switching
• Swap out with two sets of changes
• Clean branch(trucked file) before context switching
HEAD FLOW
ffffac0 acc0145 33affg3
Merged two branches
4356aca
ffffcbc 1234cd
gh-pages
master
head
Merging
• Fast-forward
• Conflict occurred when two changes on the same linear set of line
• —no-ff
• forces git to commit any way, don't do fast forward, make a
commit message
• —ff-only
• do the fast forward if you can do fast forward, if you unable
then skip
Normal merge
ffffac0 acc0145 33affg3
Merged two branches
4356aca
ffffcbc 1234cd
gh-pages
master
head
ffffaca
Truck changes to master
ffffac0 acc0145
33affgg
Merged two branches
4356aca
ffffcbc 1224cd
gh-pages
master
5556aca
6734cd
Stash
• Stash is a place where we can store changes temporarily
file without commit.
• Its not part of repo, staging index, or workspace
• Stash is available all the time, within all branches
• Stash pull does not matter which branch you are…..
Remotes
• More powerful
• It can collaborate with other
• Distributed version control
• http://github.com
master
origin/master
master
Are you fetched
from remote
branch?remote
local
Yes
Okey no
problem, you
have to merge if
needed
ffffac0 acc0145 33affg3 ffffcbc 1234cd
master
ffffac0 acc0145 33affg3 ffffcbc
master
ffffac0 acc0145 33affg3 ffffcbc 1234cd
origin/master
Fetch
You have to merge
Local repo
Remote repo
Push
• We have to push what we changes
Fetch• Read only remote we are fetching from
• Fetch before push
• Fetch before pull
Git Fetch
Tracking branch
➜ git_est git:(master) cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/cmabdullah/Demo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch “master"] //tracking
remote = origin
merge = refs/heads/master
Non tracking branch
• Git push -u origin master // -u is used to make sure it is
tracking branch
• If we do not use -u then it does not track remote branch
• It does not keep any information that this is the branch
what we are working in future…..
Non tracking branch
➜ git_est git:(master) git branch non
➜ git_est git:(master) git push origin non
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/cmabdullah/Demo.git
* [new branch] non -> non
➜ git_est git:(master) cat .git/config
➜ git_est git:(master) cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/cmabdullah/Demo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
// does not exist branch non, I.e branch non is non tracking branch
➜ git_est git:(master)
Any question?

More Related Content

What's hot

Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHubDSCVSSUT
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and GithubHouari ZEGAI
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
HacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubHacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubGDSCIIITBbsr
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists Steven Hamblin
 
Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of troubleJon Senchyna
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Omar Fathy
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 

What's hot (20)

Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Learning git
Learning gitLearning git
Learning git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Bitbucket
BitbucketBitbucket
Bitbucket
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
HacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubHacktoberFest-Git&GitHub
HacktoberFest-Git&GitHub
 
Git basics
Git basicsGit basics
Git basics
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Roslyn on GitHub
Roslyn on GitHubRoslyn on GitHub
Roslyn on GitHub
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git basic
Git basicGit basic
Git basic
 

Similar to Learn Git form Beginners to Master

Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Ahmed El-Arabawy
 
Git Workflow
Git WorkflowGit Workflow
Git WorkflowGary Yeh
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptxtnscharishma
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIsTim Osborn
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to GitMuhil Vannan
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHubVikram SV
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlowMark Everard
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubKim Moir
 

Similar to Learn Git form Beginners to Master (20)

Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
 
Git hub
Git hubGit hub
Git hub
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlow
 
GitWorkFlow
GitWorkFlowGitWorkFlow
GitWorkFlow
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Recently uploaded (20)

🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 

Learn Git form Beginners to Master

  • 1. Git • Created by Linus Torvalds • April 2005 • Distributed version control system • Open source and free software • Faster, support all platform • Safe guard against data corruption ….
  • 2. Goal • Git Installation • Git Architecture • Git Concept • Add, commit, push, pull, stash, undo • .gitignore • tree-is • Branching • Merging • Remote repository communication(team work concept)
  • 3. Github • Lunched 2008 • GitHub offers plans for both private repositories and free accounts which are commonly used to host open-source software projects. As of June 2018, GitHub reports having over 28 million users and 57 million repositories (including 28 million public repositories.),
  • 4. Distributed version control • Different users (or teams of users) maintain their own repositories, instead of working from a central repository • Changes are stored as change sets. • Git focus on change set encapsulating a change set as a discrete unit and then those change sets can be exchange between repository • No single master repository, just many working copies • Each with their own combination of change sets.
  • 5. Who is the user? • Anyone want to truck hi note • Review history log changes • View difference between two versions • Retrieve old version • Anyone need to share changes with the collaborators • Anyone not afraid of command line tools
  • 6. Install git • Mac OS • brew install git • Ubuntu • apt-get install git • Fedora • yum install git • Windows • https://git-scm.com/download/win
  • 7. Git configuration • System • User • Project User
  • 8. Main job • Make changes • add changes • Commit the changes
  • 9. Git Architecture • Three tree architecture • Add command add file staging index Repository Staging Index Working Commit Add file Pull
  • 10. what is staging index? • I have 5 file , I wanted to add 2 file, then I put 2 file in staging index and commit 2 file. Still 3 file is left, not added yet, also not commit yet, those are available in my working tree, they never added in staging index, or remote server. They are waiting for another commit.
  • 11. What is SHA? • When we change, git generate a check-sum code, checksum is an algorithm that generate number from data. • Git generate checksum using SHA-1 hash algorithm. This algorithms produce 40 digit hex number. • Goal of checksum: data didn’t change • checksum->HASH->SHA-1
  • 12. Data integrity • Git sure that you cannot change what you have committed , when you have reset any data your checksum must be changed.
  • 14. Checksum snapshot acc0145 Parent ffffac0 Author Cm Message Fix bug ffffac0 Parent Nill Author Cm Message Initial commit 33affg3 Parent acc0145 Author Cm Message Fix bug Snapshot 1 Snapshot 2 Snapshot 3
  • 15. HEAD • Head point to specific commit to the repository • If you add new commit pointer have to change to new commit. • Head point to “tip” current branch of the repository… • Not staging index or working directory • Last stage of repository what I checked out. • Head pointer is the place where we start record. • Head is the last commit of the current branch • Head always checked currently check-out branch
  • 17. --amend acc0145 Parent ffffac0 Author Cm Message Fix bug ffffac0 Parent Nill Author Cm Message Initial commit 33affg3 Parent acc0145 Author Cm Message Fix bug Snapshot 1 Snapshot 2 Snapshot 3
  • 18. Git reset • —soft • Does not change staging index or working directory. • It just move the pointer • Keep code safe zone • It move only pointer nothing else • —mixed • Change head pointer to specify commit • Change staging index to patch repository • Does not change working directory • We don’t lost any data • —hard • Change staging index and working directory to match • Any changes after this commit are completely deleted…. • Automatically garbage collection
  • 19. Caution • When you wanted to reset anything , copy last few commits and pest int a text file.
  • 20. .gitignore • *.php • *.dll • .DS_Store • log/*.log • !index.php//dont ignore….. • Ignore all file within directory directory/ • Comment lines begins with # • Git does not truck empty directory
  • 21. Compare • Comparing the commit references , what actual stage of all files in this repository at that point of time. • It means what the changes over time…..
  • 22. Branching • Don’t causes lot of headaches • Don’t take lot of processing power • Easy to created also easy to deleted • Try new ideas • Isolate features • Context switching • Swap out with two sets of changes • Clean branch(trucked file) before context switching
  • 23. HEAD FLOW ffffac0 acc0145 33affg3 Merged two branches 4356aca ffffcbc 1234cd gh-pages master head
  • 24. Merging • Fast-forward • Conflict occurred when two changes on the same linear set of line • —no-ff • forces git to commit any way, don't do fast forward, make a commit message • —ff-only • do the fast forward if you can do fast forward, if you unable then skip
  • 25. Normal merge ffffac0 acc0145 33affg3 Merged two branches 4356aca ffffcbc 1234cd gh-pages master head ffffaca
  • 26. Truck changes to master ffffac0 acc0145 33affgg Merged two branches 4356aca ffffcbc 1224cd gh-pages master 5556aca 6734cd
  • 27. Stash • Stash is a place where we can store changes temporarily file without commit. • Its not part of repo, staging index, or workspace • Stash is available all the time, within all branches • Stash pull does not matter which branch you are…..
  • 28. Remotes • More powerful • It can collaborate with other • Distributed version control • http://github.com
  • 29. master origin/master master Are you fetched from remote branch?remote local Yes Okey no problem, you have to merge if needed
  • 30. ffffac0 acc0145 33affg3 ffffcbc 1234cd master ffffac0 acc0145 33affg3 ffffcbc master ffffac0 acc0145 33affg3 ffffcbc 1234cd origin/master Fetch You have to merge Local repo Remote repo
  • 31. Push • We have to push what we changes
  • 32. Fetch• Read only remote we are fetching from • Fetch before push • Fetch before pull
  • 34. Tracking branch ➜ git_est git:(master) cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true precomposeunicode = true [remote "origin"] url = https://github.com/cmabdullah/Demo.git fetch = +refs/heads/*:refs/remotes/origin/* [branch “master"] //tracking remote = origin merge = refs/heads/master
  • 35. Non tracking branch • Git push -u origin master // -u is used to make sure it is tracking branch • If we do not use -u then it does not track remote branch • It does not keep any information that this is the branch what we are working in future…..
  • 36. Non tracking branch ➜ git_est git:(master) git branch non ➜ git_est git:(master) git push origin non Total 0 (delta 0), reused 0 (delta 0) To https://github.com/cmabdullah/Demo.git * [new branch] non -> non ➜ git_est git:(master) cat .git/config ➜ git_est git:(master) cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true precomposeunicode = true [remote "origin"] url = https://github.com/cmabdullah/Demo.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master // does not exist branch non, I.e branch non is non tracking branch ➜ git_est git:(master)