SlideShare una empresa de Scribd logo
1 de 42
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Git+github
Git+githubGit+github
Git+github
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git and github
Git and githubGit and github
Git and github
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Git이란 (Git 소개 및 기초 이론)
Git이란 (Git 소개 및 기초 이론)Git이란 (Git 소개 및 기초 이론)
Git이란 (Git 소개 및 기초 이론)
 
git and github
git and githubgit and github
git and github
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Introducing GitLab
Introducing GitLabIntroducing GitLab
Introducing GitLab
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Minicurso GIT Completo (2022)
Minicurso GIT Completo (2022)Minicurso GIT Completo (2022)
Minicurso GIT Completo (2022)
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
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
 

Similar a Git Mastery

Similar a 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
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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.