SlideShare a Scribd company logo
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

PPT
Git basic
PPTX
Git in 10 minutes
PPTX
Git and GitHub
KEY
Introduction to Git
PPTX
Git and Github Session
PDF
Intro to Git and GitHub
PPTX
Intro to git and git hub
PDF
Git and Github slides.pdf
Git basic
Git in 10 minutes
Git and GitHub
Introduction to Git
Git and Github Session
Intro to Git and GitHub
Intro to git and git hub
Git and Github slides.pdf

What's hot (20)

PDF
Git and github 101
PDF
Starting with Git & GitHub
PPTX
GIT presentation
PDF
Git & GitHub WorkShop
PPTX
Introduction git
PDF
Introduction to Git and Github
PDF
Introduction to Git and GitHub
PPTX
PPTX
Migrating To GitHub
PDF
Git training v10
PDF
Advanced Git
PPTX
Introduction to git hub
PPTX
Github basics
KEY
The everyday developer's guide to version control with Git
PDF
Git 101: Git and GitHub for Beginners
PPTX
Git & git hub
PDF
Git - An Introduction
PDF
Git Introduction Tutorial
PPTX
Git - Basic Crash Course
PDF
やりなおせる Git 入門
Git and github 101
Starting with Git & GitHub
GIT presentation
Git & GitHub WorkShop
Introduction git
Introduction to Git and Github
Introduction to Git and GitHub
Migrating To GitHub
Git training v10
Advanced Git
Introduction to git hub
Github basics
The everyday developer's guide to version control with Git
Git 101: Git and GitHub for Beginners
Git & git hub
Git - An Introduction
Git Introduction Tutorial
Git - Basic Crash Course
やりなおせる Git 入門
Ad

Similar to Learn Git form Beginners to Master (20)

PPTX
Introduction to git, a version control system
PPTX
Git_new.pptx
PPTX
Git and Github
PPTX
Git and github
PPTX
01 - Git vs SVN
PPTX
Git and Github workshop GDSC MLRITM
PPTX
Git Basics for Software Version Management
PDF
devops-complete-notes-2.pdf
PPTX
GIT.pptx
PPTX
Git 101 - An introduction to Version Control using Git
PDF
Git of every day
PDF
Git basics with notes
PPTX
git.ppt.pptx power point presentation got Google internet
PPTX
Lets Git Together
PDF
Version control with GIT
PDF
Git Intermediate Workshop slides v1.3
PDF
Git training
KEY
Getting Git
PPTX
sample.pptx
PDF
Introduction to Git (part 1)
Introduction to git, a version control system
Git_new.pptx
Git and Github
Git and github
01 - Git vs SVN
Git and Github workshop GDSC MLRITM
Git Basics for Software Version Management
devops-complete-notes-2.pdf
GIT.pptx
Git 101 - An introduction to Version Control using Git
Git of every day
Git basics with notes
git.ppt.pptx power point presentation got Google internet
Lets Git Together
Version control with GIT
Git Intermediate Workshop slides v1.3
Git training
Getting Git
sample.pptx
Introduction to Git (part 1)
Ad

Recently uploaded (20)

PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
Construction Project Organization Group 2.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
DOCX
573137875-Attendance-Management-System-original
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
OOP with Java - Java Introduction (Basics)
PDF
PPT on Performance Review to get promotions
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Lecture Notes Electrical Wiring System Components
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Foundation to blockchain - A guide to Blockchain Tech
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Sustainable Sites - Green Building Construction
Construction Project Organization Group 2.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
CYBER-CRIMES AND SECURITY A guide to understanding
573137875-Attendance-Management-System-original
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
OOP with Java - Java Introduction (Basics)
PPT on Performance Review to get promotions
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Lecture Notes Electrical Wiring System Components

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)