SlideShare a Scribd company logo
1 of 42
Download to read offline
Muhammad Rizwan – Corvit Systems
Git Mastery
What is Git?
Tracking changes in our work
for reproducibility and collaboration.
What is Git?
Git is a free and open source
distributed version control system designed to handle
everything from small to very large projects with speed and efficiency.
It was created by Linus Torvalds in 2005 to develop Linux Kernel.
Git has the functionality, performance, security and flexibility that most
teams and individual developers need. It also serves as an important
distributed version-control DevOps tool.
Git Intuition
Whether we're working individually or with a team, it's important that
we have a system to track changes to our projects so that we can
revert to previous versions and so that others can reproduce our work
and contribute to it. Git is a distributed versional control system that
allows us do exactly this. Git runs locally on our computer and it keeps
track of our files and their histories. To enable collaboration with
others, we can use a remote host (GitHub, GitLab, BitBucket, etc.) to
host our files and their histories. We'll use git to push our local changes
and pull other's changes to and from the remote host.
You wanted to cook a new dish
After a lot of trail and error, you made your first version of dish
You want to improvise your dish
So you add few other ingredients and make a 2nd version of your dish
You are still not satisfied
So you again improvise your recipe and make a
new 3rd version of your dish
And what if you have a team
and everyone wanted to taste each version of your dish
and add their own ingredients
and contribute to your masterpiece
Everything is messed up
Wouldn’t it be great if there was a time machine
which stores all your recipes and dishes separately
so if something goes wrong you could go back to the previous dish
That is where GIT comes into play
Git is a distributed version control system
Git track the changes you made, so you have a record of what has been done, and
you can revert to specific versions. It make collaboration easier, allowing changes
by multiple people to all be merged into one source.
Earlier Developer
Earlier developer would have their Backup source code
in separate folders. Reverting back and collaborating is a tedious job.
Types of VCS
- Centralized Version Control System (CVCS)
- Distributed Version Control System (DVCS)
Centralized Version Control System
Centralized version control system (CVCS) uses a central server to store
all files and enables team collaboration. It works on a single repository
to which users can directly access a central server.
> It is not locally available; meaning you always
need to be connected to a network to perform any
action.
> Since everything is centralized, in any case of the
central server getting crashed or corrupted will
result in losing the entire data of the project.
Distributed Version Control System
In Distributed VCS, every contributor has a local copy or “clone” of the
main repository i.e. everyone maintains a local repository of their own
which contains all the files and metadata present in the main
repository.
> Committing new change-sets can be done locally without
manipulating the data on the main repository. Once you have
a group of change-sets ready, you can push them all at once.
> Since every contributor has a full copy of the project
repository, they can share changes with one another if they
want to get some feedback before affecting changes in the
main repository.
> If the central server gets crashed at any point of time, the
lost data can be easily recovered from any one of the
contributor’s local repositories.
Features of Git
Git provides with all the Distributed VCS facilities to the user that was
mentioned earlier. Git repositories are very easy to find and access.
Some companies that use Git for version control are: Facebook, Zynga,
Quora, Twitter, eBay, Salesforce, Microsoft and many more.
- Free and open source
- Speed, Scalable, Secure, Reliable, Economical
- Support Non-linear development
- Distributed development, Easy Branching
Git
Git can automatically merge the changes, so two people can even
work on different parts of the same file and later merge those changes
without losing each other’s work!
master
your work
Someone else’s work
Role of Git in DevOps?
Git is an integral part of DevOps.
DevOps promotes communication between development engineers
and operations, participating together in the entire service life-cycle,
from design through the development process to production support.
DevOps
DevOps life-cycle & display how Git fits in DevOps
Code
Shared
Repository
Continuous
Integration
Build
Test
Configuration
Management
Deploy
Monitor
Plan
Git – set up
We need to create a GitHub (or any other remote host) account first
and set our credentials globally on our local machine.
# Set credentials via terminal
~$ git config --global user.name <username>
~$ git config --global user.email <email>
Git – set up
We can quickly validate that we set the proper credentials like so:
# Check credentials
~$ git config --global user.name
~$ git config --global user.email
# View all your configuration details
~$ git config --list
Git – Create
Create a project in a working directory.
# Create project
~$ mkdir project1
~$ cd project1
Git – Create
We'll add some simple files. First will be a README.md and then
another file called do_not_push.txt which we won't check into our
repository.
# Create some files
~$ touch README.md do_not_push.txt .gitignore
Git – Create
Now we'll go ahead and add some text to our README.md file. We can
simply open the file in an IDE (ex. VS Code) and add some text into it.
~$ code .
Initialize Git
Initialize Git
Initialize a local repository (.git directory) to track our files.
# Initialize git
~$ git init
Initialize Git
We can see what files are untracked or yet to be committed.
# Check status
~$ git status
Git status
Git – Add to stage
Add our work from the working directory to the staging area.
We can add one file at a time:
# Add a file to stage
~$ git add README.md
We can add all files:
# Add all files to stage
~$ git add .
~$ git status
Git – Add to stage
Git – Commit to repo
Commit the files in the staging area to the local repository.
The default branch will be called master as it will be the master
branch all future work will eventually merge with.
# Commit to local repo
~$ git commit -m “initial commit”
The commit requires a message indicating what changes took place.
Git – Commit to repo
Git – Commit to repo
If we do a git status check we'll see that there is nothing else to commit
from our staging area.
Git – Push to remote
Push our commit to a remote repository (GitHub).
We only need to add the remote origin address once and then we can
push our local repository to the remote with a simple push command.
# Push to remote
~$ git remote add origin
https://github.com/mrizwanse/project1.git
~$ git push -u origin master
We first need to create a new remote repository to push
our commit to by filling out GitHub form (make sure
we're logged into GitHub first). Let's call the repository
project1 and don't add any of the default files since we
already have them. Once we're done, we'll see a HTTPS
link like above which we can use to establish the
connection between our local and the remote
repositories. Now if we go our GitHub repository link,
we'll see the files that we pushed.
Git – Push to remote
Pushing the contents of our master branch to the remote repository,
origin is short for the name of the remote repository.
Git – Push to remote
Git – Push to remote
Why is Git so popular?
Git is a distributed version control system(VCS) that enables the
developers to manage the changes offline and allows you to branch
and merge whenever required, giving them full control over the local
code base. It is fast and also suitable for handling massive code bases
scattered across multiple developers, which makes it the most popular
tool used.
What is the difference between Git vs GitHub?
Git is just a version control system that manages and tracks changes to
your source code whereas
GitHub is a cloud-based hosting platform that manages all your Git
repositories.

More Related Content

What's hot

Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionAnwarul Islam
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow IntroductionDavid Paluy
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
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
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
WorkShop: Introducción a GIT
WorkShop: Introducción a GITWorkShop: Introducción a GIT
WorkShop: Introducción a GITKeopx
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
svn 능력자를 위한 git 개념 가이드
svn 능력자를 위한 git 개념 가이드svn 능력자를 위한 git 개념 가이드
svn 능력자를 위한 git 개념 가이드Insub Lee
 

What's hot (20)

Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git flow
Git flowGit flow
Git flow
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & 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 ...
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Git basic
Git basicGit basic
Git basic
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
WorkShop: Introducción a GIT
WorkShop: Introducción a GITWorkShop: Introducción a GIT
WorkShop: Introducción a GIT
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Learning git
Learning gitLearning git
Learning git
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git
GitGit
Git
 
svn 능력자를 위한 git 개념 가이드
svn 능력자를 위한 git 개념 가이드svn 능력자를 위한 git 개념 가이드
svn 능력자를 위한 git 개념 가이드
 

Similar to Git Mastery

Similar to Git Mastery (20)

Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git session 1
Git session 1Git session 1
Git session 1
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Git Tutorial
Git Tutorial Git Tutorial
Git Tutorial
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git introduction
Git introductionGit introduction
Git introduction
 
Git and github
Git and githubGit and github
Git and github
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
 
git Introduction.pptx
git Introduction.pptxgit Introduction.pptx
git Introduction.pptx
 

Recently uploaded

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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Git Mastery

  • 1. Muhammad Rizwan – Corvit Systems Git Mastery
  • 2. What is Git? Tracking changes in our work for reproducibility and collaboration.
  • 3. What is Git? Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It was created by Linus Torvalds in 2005 to develop Linux Kernel. Git has the functionality, performance, security and flexibility that most teams and individual developers need. It also serves as an important distributed version-control DevOps tool.
  • 4. Git Intuition Whether we're working individually or with a team, it's important that we have a system to track changes to our projects so that we can revert to previous versions and so that others can reproduce our work and contribute to it. Git is a distributed versional control system that allows us do exactly this. Git runs locally on our computer and it keeps track of our files and their histories. To enable collaboration with others, we can use a remote host (GitHub, GitLab, BitBucket, etc.) to host our files and their histories. We'll use git to push our local changes and pull other's changes to and from the remote host.
  • 5. You wanted to cook a new dish After a lot of trail and error, you made your first version of dish
  • 6. You want to improvise your dish So you add few other ingredients and make a 2nd version of your dish
  • 7. You are still not satisfied So you again improvise your recipe and make a new 3rd version of your dish
  • 8. And what if you have a team and everyone wanted to taste each version of your dish and add their own ingredients and contribute to your masterpiece
  • 9. Everything is messed up Wouldn’t it be great if there was a time machine which stores all your recipes and dishes separately so if something goes wrong you could go back to the previous dish
  • 10. That is where GIT comes into play Git is a distributed version control system Git track the changes you made, so you have a record of what has been done, and you can revert to specific versions. It make collaboration easier, allowing changes by multiple people to all be merged into one source.
  • 11. Earlier Developer Earlier developer would have their Backup source code in separate folders. Reverting back and collaborating is a tedious job.
  • 12. Types of VCS - Centralized Version Control System (CVCS) - Distributed Version Control System (DVCS)
  • 13. Centralized Version Control System Centralized version control system (CVCS) uses a central server to store all files and enables team collaboration. It works on a single repository to which users can directly access a central server. > It is not locally available; meaning you always need to be connected to a network to perform any action. > Since everything is centralized, in any case of the central server getting crashed or corrupted will result in losing the entire data of the project.
  • 14. Distributed Version Control System In Distributed VCS, every contributor has a local copy or “clone” of the main repository i.e. everyone maintains a local repository of their own which contains all the files and metadata present in the main repository. > Committing new change-sets can be done locally without manipulating the data on the main repository. Once you have a group of change-sets ready, you can push them all at once. > Since every contributor has a full copy of the project repository, they can share changes with one another if they want to get some feedback before affecting changes in the main repository. > If the central server gets crashed at any point of time, the lost data can be easily recovered from any one of the contributor’s local repositories.
  • 15. Features of Git Git provides with all the Distributed VCS facilities to the user that was mentioned earlier. Git repositories are very easy to find and access. Some companies that use Git for version control are: Facebook, Zynga, Quora, Twitter, eBay, Salesforce, Microsoft and many more. - Free and open source - Speed, Scalable, Secure, Reliable, Economical - Support Non-linear development - Distributed development, Easy Branching
  • 16. Git Git can automatically merge the changes, so two people can even work on different parts of the same file and later merge those changes without losing each other’s work! master your work Someone else’s work
  • 17. Role of Git in DevOps? Git is an integral part of DevOps. DevOps promotes communication between development engineers and operations, participating together in the entire service life-cycle, from design through the development process to production support.
  • 19. DevOps life-cycle & display how Git fits in DevOps Code Shared Repository Continuous Integration Build Test Configuration Management Deploy Monitor Plan
  • 20. Git – set up We need to create a GitHub (or any other remote host) account first and set our credentials globally on our local machine. # Set credentials via terminal ~$ git config --global user.name <username> ~$ git config --global user.email <email>
  • 21. Git – set up We can quickly validate that we set the proper credentials like so: # Check credentials ~$ git config --global user.name ~$ git config --global user.email # View all your configuration details ~$ git config --list
  • 22. Git – Create Create a project in a working directory. # Create project ~$ mkdir project1 ~$ cd project1
  • 23. Git – Create We'll add some simple files. First will be a README.md and then another file called do_not_push.txt which we won't check into our repository. # Create some files ~$ touch README.md do_not_push.txt .gitignore
  • 24. Git – Create Now we'll go ahead and add some text to our README.md file. We can simply open the file in an IDE (ex. VS Code) and add some text into it. ~$ code .
  • 26. Initialize Git Initialize a local repository (.git directory) to track our files. # Initialize git ~$ git init
  • 27.
  • 28. Initialize Git We can see what files are untracked or yet to be committed. # Check status ~$ git status
  • 30. Git – Add to stage Add our work from the working directory to the staging area. We can add one file at a time: # Add a file to stage ~$ git add README.md We can add all files: # Add all files to stage ~$ git add . ~$ git status
  • 31. Git – Add to stage
  • 32. Git – Commit to repo Commit the files in the staging area to the local repository. The default branch will be called master as it will be the master branch all future work will eventually merge with. # Commit to local repo ~$ git commit -m “initial commit” The commit requires a message indicating what changes took place.
  • 33. Git – Commit to repo
  • 34. Git – Commit to repo If we do a git status check we'll see that there is nothing else to commit from our staging area.
  • 35. Git – Push to remote Push our commit to a remote repository (GitHub). We only need to add the remote origin address once and then we can push our local repository to the remote with a simple push command. # Push to remote ~$ git remote add origin https://github.com/mrizwanse/project1.git ~$ git push -u origin master
  • 36. We first need to create a new remote repository to push our commit to by filling out GitHub form (make sure we're logged into GitHub first). Let's call the repository project1 and don't add any of the default files since we already have them. Once we're done, we'll see a HTTPS link like above which we can use to establish the connection between our local and the remote repositories. Now if we go our GitHub repository link, we'll see the files that we pushed.
  • 37. Git – Push to remote Pushing the contents of our master branch to the remote repository, origin is short for the name of the remote repository.
  • 38. Git – Push to remote
  • 39. Git – Push to remote
  • 40.
  • 41. Why is Git so popular? Git is a distributed version control system(VCS) that enables the developers to manage the changes offline and allows you to branch and merge whenever required, giving them full control over the local code base. It is fast and also suitable for handling massive code bases scattered across multiple developers, which makes it the most popular tool used.
  • 42. What is the difference between Git vs GitHub? Git is just a version control system that manages and tracks changes to your source code whereas GitHub is a cloud-based hosting platform that manages all your Git repositories.