SlideShare a Scribd company logo
1 of 50
Download to read offline
Version
Control
GIT
DevOps course by Abdul Rahim
Introduction to Version
Control System (VCS)
– Version Control (aka Revision Control aka Source Control)
is a system that records changes to a file or set of files
over time so that you can recall specific versions later.
– Why do you care? So when you mess up you can easily
get back to a previous working version.
– It is very helpful when multiple users are continuously
working or changing a document.
DevOps course by Abdul Rahim
Using VCS, the Users can review the document history to
find out the following details:
– Which changes were made in the document?
– Who made the changes in the document?
– When were the changes made in the document?
– Why were changes needed?
Advantages of Version
Control System
DevOps course by Abdul Rahim
Advantages of Version
Control System
A good VCS does the following:
– Backup and Restore.
– Synchronization.
– Short-term undo
– Long-term undo.
– Track Changes.
– Track Ownership.
– Sandboxing, or insurance against yourself.
– Branching and merging
DevOps course by Abdul Rahim
Type Of VCS
There are two types of VCS, namely:
– Local Version Control Systems (LVCS).
– Centralized version control system (CVCS).
– Distributed version control system (DVCS).
DevOps course by Abdul Rahim
Local Version Control
Systems (LVCS)
– You’ve probably cooked up your own version control system without realizing it
had such a geeky name. Got any files like this?
– Rahim-Resume-Oct2014.docx
– Rahim-Resume-Mar2015.docx
– Rahim-Resume-Mar2015-OLD.docx
– It’s why we use “Save As”. You want the new file without obliterating the old one.
It’s a common problem, and solutions are usually like this:
– Make a single backup copy (Document.old.txt).
– If we’re clever, we add a version number or date: CV_V1.txt or CVMarch2015.txt
– We may even use a shared folder so other people can see and edit files without sending
them over email. Hopefully they relabel the file after they save it.
DevOps course by Abdul Rahim
Centralized version
control system (CVCS)
DevOps course by Abdul Rahim
Centralized version
control system (CVCS)
DevOps course by Abdul Rahim
– Centralized version control system works on a Client-Server
relationship. Server will have all the information which is
transferred to the client.
– The main disadvantage of the Centralized VCS is that it is a single
point of failure. If central server went down then you cannot used
it.
1. Concurrent Versions System (CVS).
2. Subversion (SVN).
3. TeamCity.
Distributed version
control system (DVCS)
DevOps course by Abdul Rahim
Distributed version
control system (DVCS)
DevOps course by Abdul Rahim
– Distributed version control system has a centralized repository as
well as all developers have local copy of repository.
– Developers can work on their local copy simultaneously. If the
central server went down then also there will be no impact
because of the local repository.
1. Git.
2. Mercurial.
3. Bazaar.
4. Visual Studio Team Services
Git Features
– Tracks history
– Free and open source
– Supports non-linear development
– Creates backups
– Scalable
– Supports collaboration
– Branching is easier
– Distributed development
– Secure
DevOps course by Abdul Rahim
Git 3-Tree Architecture /
Workflow
DevOps course by Abdul Rahim
Lab – Git
DevOps course by Abdul Rahim
1. Install Git
2. Setting up name and e-mail address
3. Add SSH key
4. Creating Github Account
If you already have Git installed and Github account, skip the lab
and help others.
Lab 1– Install Git
DevOps course by Abdul Rahim
• https://git-scm.com/download/winWindows
• sudo apt-get install git-all
• https://git-scm.com/download/linuxUbuntu
• brew install git
• https://git-scm.com/download/macMacOS
Lab 2– Setting up name
and e-mail address
DevOps course by Abdul Rahim
– If you've never used git before, first you
need to set up your name and e-mail. Open
Git Bash & run the following commands to
let git know your name and e-mail address.
git config --global user.name "Your Name"
git config --global user.email "your_email@whatever.com"
Lab 3– Add SSH key
DevOps course by Abdul Rahim
– For pushing changes to Github/cloning a private repo, it needs to authenticate
you, so for every push, you will have to enter your username & password which
can cause problems. So to solve that we can add an SSH key of your PC, so that
Github knows whenever you are trying to clone/push changes, that this PC is
secured and has SSH(secure shell).
– Generate SSH key locally
– ssh-keygen -t rsa -b 4096 -C "your_email@whatever.com"
– eval $(ssh-agent -s)
– ssh-add ~/.ssh/id_rsa
– cat ~/.ssh/id_rsa.pub
Lab 3– Add SSH key
DevOps course by Abdul Rahim
– Copy the SSH key and then we need to go to the GitHub account and click on
– Profile -> Settings -> SSH & GPG Keys -> New SSH Key -> Paste.
– This will add an SSH key to your account, to test if it is working enter
– ssh -T git@github.com
Lab 4– Creating Github
Account
DevOps course by Abdul Rahim
– Go to https://www.github.com/ and Signup
– your username will be your github address e.g.
https://github.com/rahimkhanabdul
Git Staging
DevOps course by Abdul Rahim
Basic Git Commands
DevOps course by Abdul Rahim
Basic Git Commands
DevOps course by Abdul Rahim
git --version git init git merge
git config --list git add <options> git rebase
git config --help git rm/mv <options> git push
git config --global git commit <options> git pull
git log git diff git checkout
git status git reset git fetch
git stash git branch git add origin
git stash apply
GIT Repository
DevOps course by Abdul Rahim
– A repository is the most basic element and a virtual storage
of your project. It allows you to save versions of your code,
which you can access when needed.
– Can be
 Private: Only certain people with access can see the repo
 Public: Anyone can see the repo
– There is a local repository & a remote repository, you make
changes to local repository and push them to remote.
Obtain a GIT Repository
DevOps course by Abdul Rahim
– You typically obtain a Git repository in one of two ways:
1. You can take a local directory that is currently not under
version control, and turn it into a Git repository, or
2. You can clone an existing Git repository from elsewhere.
– In either case, you end up with a Git repository on your
local machine, ready for work.
Initializing / Creating a
Local Repository
DevOps course by Abdul Rahim
– If you have a project directory that is currently not under version control and
you want to start controlling it with Git, you first need to go to that project’s
directory.
– Open GIT Bash
cd <project-directory>
– and type:
git init
– This creates a new subdirectory named .git into your <project-
directory> that contains all of your necessary repository files — a
Git repository skeleton.
Create a Remote
Repository
DevOps course by Abdul Rahim
– Login to www.github.com
– Click the + at the top right,
– New Repository,
– Enter Repository Name, Description, Chose Public and
initialize with a README.
– Click create repository
– Your Repository will be created with following link
github.com/<username>/<repo-name>
Connect Local & Remote
Repository
DevOps course by Abdul Rahim
– Open Git bash and Run the command
git remote add origin https://github.com/<user-name>/<repo-name>.git
– Push the file to the remote repository.
git push origin master
Cloning an Existing
Repository
DevOps course by Abdul Rahim
– You can clone a repo, by clicking the code button, and
copying the link. Go to git bash
– Using https
git clone https://github.com/<user-name>/<repo-name>.git
– Using ssh
git clone git@github.com:<user-name>/<repo-name>.git
– Download Zip
LAB - GIT Commands
DevOps course by Abdul Rahim
1. Make changes to your project
2. Checking File Differences
3. Commit changes to your local repository
4. Resetting Differences
LAB 5- Make changes to
your project
DevOps course by Abdul Rahim
– Create a “hello.html” file in it with the following contents
<h1>Hello, World!<h1>
– Check the current state of the repository.
git status
– Meaning “hello.html” file is added that is currently untracked i.e. it
is not present in git history
LAB 6- Checking File
Differences
DevOps course by Abdul Rahim
– Now let’s add the page to staging area of the repository.
git add hello.html or git add .
git status
– It means file is in staging, but it should be committed to
local repo.
LAB 6- Checking File
Differences
DevOps course by Abdul Rahim
– Now edit the README.md file, add a bit description like "This is a
test repository" or anything else.
– Check the working directory’s status.
git status
– It shows that new file “hello.html” is yet to be committed, and
“README.md” has been modified but it needs to be staged for
commit first.
LAB 6- Checking File
Differences
DevOps course by Abdul Rahim
– Now see the differences that have been made
git diff
– It shows that text with - sign was removed and + sign were
added.
LAB 6- Checking File
Differences
DevOps course by Abdul Rahim
– Add “README.md” file to staging. And then check status
git status
– It shows that a new file “hello.html” has added and
“README.md” file modified, but yet to be committed
LAB 6- Checking File
Differences
DevOps course by Abdul Rahim
– Check differences in staging area
git diff –staged
– It shows both the differences of README.md as well as
a.txt.
LAB 7- Commit changes to
your local repository
DevOps course by Abdul Rahim
– Now we will commit the changes in the local repository
git commit –m ‘first commit’
git status
– It shows that your local branch is ahead of origin/master
by 1 commit that we just did. The working tree is clean
and there are no changes to record.
LAB 8- Resetting
Differences
DevOps course by Abdul Rahim
– Now we have two changes in a commit. We want to reset
these differences. There are 3 possible options.
1. MIXED (Default Method)
Remove the commit from local repo, and also remove changes from staging area
2. SOFT
Remove the commit from local repo, but keep the files in staging area
3. HARD
Remove the commit from local repo, and staging area and even change the
local files.
Method-1 Mixed
(Default Method)
DevOps course by Abdul Rahim
 git reset –mixed HEAD^
– Notice changes have been removed from local repo as well as
staging area. So we will need to add and commit files again.
Method-2 Soft
DevOps course by Abdul Rahim
 git reset –soft HEAD^
– Notice that files are still in staging area but have been
removed from local repo, now you will just need to
commit them again.
Method-3 Hard
DevOps course by Abdul Rahim
 git reset –hard HEAD^
– Notice the changes have been removed from local repo, as
well as the working tree i.e. the files are now in initial state
that was before your working.
PUSH And PULL
DevOps course by Abdul Rahim
– PUSH
– Transfer commits from your local repository to a
remote repository.
– Share modifications with remote team members.
– Commands
 git push origin
PUSH And PULL
DevOps course by Abdul Rahim
– PULL
– Download content from a remote repository and
update the local repository
– Get modification from remote team members
– Commands
 git pull origin
LAB - PUSH And PULL
DevOps course by Abdul Rahim
1. Push to Remote Repository
2. Pull from Remote Repository
LAB 1- Push to Remote
Repository
DevOps course by Abdul Rahim
– Let’s create the “hello.html” file in it with the following
contents
<h1>Hello, World!<h1>
– Now add and commit the file
– git add .
– git commit –m ‘first commit’
LAB 1- Push to Remote
Repository
DevOps course by Abdul Rahim
– Your current changes are in the local repository to verify
that go to Github and verify that “hello.html” does not
exist. Push changes from local repository using the
command:
– git push origin master
LAB 2- Pull from Remote
Repository
DevOps course by Abdul Rahim
– You will create a file on Github and then pull those changes in your
local repository
– Go to your Github repository that you created and create new file.
LAB 2- Pull from Remote
Repository
DevOps course by Abdul Rahim
LAB 2- Pull from Remote
Repository
DevOps course by Abdul Rahim
– Next you will pull the latest changes from remote to local
repository
Github Pages
DevOps course by Abdul Rahim
– GitHub Pages is a static site hosting service that takes HTML, CSS, and
JavaScript files straight from a repository on GitHub, optionally runs the
files through a build process, and publishes a website.
– You can use GitHub Pages to host a website about yourself, your
organization, or your project directly from a GitHub repository.
– You get one site per GitHub account and organization, and unlimited
project sites.
– Does not support server side code such as PHP, Python or Ruby
– GitHub Pages are publicly available on the internet, even if their
repositories are private.
ASSIGNMENT
DevOps course by Abdul Rahim
– HOST YOUR RESUME ON GITHUB PAGES
– INSTRUCTIONS
 Create your Resume Repository on GitHub
 Host it through GitHub Pages
Reference
DevOps course by Abdul Rahim
– https://git-scm.com/
– https://www.simplilearn.com/tutorials/git-tutorial/what-is-git
– https://www.atlassian.com/git/tutorials/why-git
– https://www.designveloper.com/blog/git-concepts-architecture/
– https://www.youtube.com/
– https://githowto.com/
– https://pages.github.com/
– https://docs.github.com/en/github/working-with-github-pages

More Related Content

What's hot

Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial IIJim Yeh
 
Totalsvn Usage And Administration By Gopi
Totalsvn Usage And Administration By GopiTotalsvn Usage And Administration By Gopi
Totalsvn Usage And Administration By Gopigopinathkarangula
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Introduction to Subversion and Google Project Hosting
Introduction to Subversion and Google Project HostingIntroduction to Subversion and Google Project Hosting
Introduction to Subversion and Google Project HostingPhilip Johnson
 
Subversion client
Subversion clientSubversion client
Subversion clientrchakra
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins UsersJules Pierre-Louis
 
Using a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareChris Jean
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins UsersJules Pierre-Louis
 
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
 
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeVoxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeDamien Duportal
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateSteffen Gebert
 
Subversion workshop
Subversion workshopSubversion workshop
Subversion workshopTrafeX
 
SVN Best Practices
SVN Best PracticesSVN Best Practices
SVN Best Practicesabackstrom
 
GIT presentation
GIT presentationGIT presentation
GIT presentationNaim Latifi
 

What's hot (20)

Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
 
Totalsvn Usage And Administration By Gopi
Totalsvn Usage And Administration By GopiTotalsvn Usage And Administration By Gopi
Totalsvn Usage And Administration By Gopi
 
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 Subversion and Google Project Hosting
Introduction to Subversion and Google Project HostingIntroduction to Subversion and Google Project Hosting
Introduction to Subversion and Google Project Hosting
 
Subversion client
Subversion clientSubversion client
Subversion client
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users
 
Using a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging Software
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
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
 
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as codeVoxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
Voxxed Luxembourd 2016 Jenkins 2.0 et Pipeline as code
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a Certificate
 
Subversion workshop
Subversion workshopSubversion workshop
Subversion workshop
 
SVN Best Practices
SVN Best PracticesSVN Best Practices
SVN Best Practices
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 

Similar to Version control git - lecture-1

Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Version control with git
Version control with gitVersion control with git
Version control with gitPurav Gandhi
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
 
Git & version control crash course
Git & version control crash course Git & version control crash course
Git & version control crash course Eslam Saeed
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 
Version control
Version controlVersion control
Version controlSean Hayes
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GITZeeshan Khan
 

Similar to Version control git - lecture-1 (20)

Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
Git 101
Git 101Git 101
Git 101
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Version control with git
Version control with gitVersion control with git
Version control with git
 
GitHub Presentation
GitHub PresentationGitHub Presentation
GitHub Presentation
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
 
Git & version control crash course
Git & version control crash course Git & version control crash course
Git & version control crash course
 
CICD_1670665418.pdf
CICD_1670665418.pdfCICD_1670665418.pdf
CICD_1670665418.pdf
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Version control
Version controlVersion control
Version control
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
 
Git
GitGit
Git
 

Recently uploaded

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Version control git - lecture-1

  • 2. Introduction to Version Control System (VCS) – Version Control (aka Revision Control aka Source Control) is a system that records changes to a file or set of files over time so that you can recall specific versions later. – Why do you care? So when you mess up you can easily get back to a previous working version. – It is very helpful when multiple users are continuously working or changing a document. DevOps course by Abdul Rahim
  • 3. Using VCS, the Users can review the document history to find out the following details: – Which changes were made in the document? – Who made the changes in the document? – When were the changes made in the document? – Why were changes needed? Advantages of Version Control System DevOps course by Abdul Rahim
  • 4. Advantages of Version Control System A good VCS does the following: – Backup and Restore. – Synchronization. – Short-term undo – Long-term undo. – Track Changes. – Track Ownership. – Sandboxing, or insurance against yourself. – Branching and merging DevOps course by Abdul Rahim
  • 5. Type Of VCS There are two types of VCS, namely: – Local Version Control Systems (LVCS). – Centralized version control system (CVCS). – Distributed version control system (DVCS). DevOps course by Abdul Rahim
  • 6. Local Version Control Systems (LVCS) – You’ve probably cooked up your own version control system without realizing it had such a geeky name. Got any files like this? – Rahim-Resume-Oct2014.docx – Rahim-Resume-Mar2015.docx – Rahim-Resume-Mar2015-OLD.docx – It’s why we use “Save As”. You want the new file without obliterating the old one. It’s a common problem, and solutions are usually like this: – Make a single backup copy (Document.old.txt). – If we’re clever, we add a version number or date: CV_V1.txt or CVMarch2015.txt – We may even use a shared folder so other people can see and edit files without sending them over email. Hopefully they relabel the file after they save it. DevOps course by Abdul Rahim
  • 7. Centralized version control system (CVCS) DevOps course by Abdul Rahim
  • 8. Centralized version control system (CVCS) DevOps course by Abdul Rahim – Centralized version control system works on a Client-Server relationship. Server will have all the information which is transferred to the client. – The main disadvantage of the Centralized VCS is that it is a single point of failure. If central server went down then you cannot used it. 1. Concurrent Versions System (CVS). 2. Subversion (SVN). 3. TeamCity.
  • 9. Distributed version control system (DVCS) DevOps course by Abdul Rahim
  • 10. Distributed version control system (DVCS) DevOps course by Abdul Rahim – Distributed version control system has a centralized repository as well as all developers have local copy of repository. – Developers can work on their local copy simultaneously. If the central server went down then also there will be no impact because of the local repository. 1. Git. 2. Mercurial. 3. Bazaar. 4. Visual Studio Team Services
  • 11. Git Features – Tracks history – Free and open source – Supports non-linear development – Creates backups – Scalable – Supports collaboration – Branching is easier – Distributed development – Secure DevOps course by Abdul Rahim
  • 12. Git 3-Tree Architecture / Workflow DevOps course by Abdul Rahim
  • 13. Lab – Git DevOps course by Abdul Rahim 1. Install Git 2. Setting up name and e-mail address 3. Add SSH key 4. Creating Github Account If you already have Git installed and Github account, skip the lab and help others.
  • 14. Lab 1– Install Git DevOps course by Abdul Rahim • https://git-scm.com/download/winWindows • sudo apt-get install git-all • https://git-scm.com/download/linuxUbuntu • brew install git • https://git-scm.com/download/macMacOS
  • 15. Lab 2– Setting up name and e-mail address DevOps course by Abdul Rahim – If you've never used git before, first you need to set up your name and e-mail. Open Git Bash & run the following commands to let git know your name and e-mail address. git config --global user.name "Your Name" git config --global user.email "your_email@whatever.com"
  • 16. Lab 3– Add SSH key DevOps course by Abdul Rahim – For pushing changes to Github/cloning a private repo, it needs to authenticate you, so for every push, you will have to enter your username & password which can cause problems. So to solve that we can add an SSH key of your PC, so that Github knows whenever you are trying to clone/push changes, that this PC is secured and has SSH(secure shell). – Generate SSH key locally – ssh-keygen -t rsa -b 4096 -C "your_email@whatever.com" – eval $(ssh-agent -s) – ssh-add ~/.ssh/id_rsa – cat ~/.ssh/id_rsa.pub
  • 17. Lab 3– Add SSH key DevOps course by Abdul Rahim – Copy the SSH key and then we need to go to the GitHub account and click on – Profile -> Settings -> SSH & GPG Keys -> New SSH Key -> Paste. – This will add an SSH key to your account, to test if it is working enter – ssh -T git@github.com
  • 18. Lab 4– Creating Github Account DevOps course by Abdul Rahim – Go to https://www.github.com/ and Signup – your username will be your github address e.g. https://github.com/rahimkhanabdul
  • 19. Git Staging DevOps course by Abdul Rahim
  • 20. Basic Git Commands DevOps course by Abdul Rahim
  • 21. Basic Git Commands DevOps course by Abdul Rahim git --version git init git merge git config --list git add <options> git rebase git config --help git rm/mv <options> git push git config --global git commit <options> git pull git log git diff git checkout git status git reset git fetch git stash git branch git add origin git stash apply
  • 22. GIT Repository DevOps course by Abdul Rahim – A repository is the most basic element and a virtual storage of your project. It allows you to save versions of your code, which you can access when needed. – Can be  Private: Only certain people with access can see the repo  Public: Anyone can see the repo – There is a local repository & a remote repository, you make changes to local repository and push them to remote.
  • 23. Obtain a GIT Repository DevOps course by Abdul Rahim – You typically obtain a Git repository in one of two ways: 1. You can take a local directory that is currently not under version control, and turn it into a Git repository, or 2. You can clone an existing Git repository from elsewhere. – In either case, you end up with a Git repository on your local machine, ready for work.
  • 24. Initializing / Creating a Local Repository DevOps course by Abdul Rahim – If you have a project directory that is currently not under version control and you want to start controlling it with Git, you first need to go to that project’s directory. – Open GIT Bash cd <project-directory> – and type: git init – This creates a new subdirectory named .git into your <project- directory> that contains all of your necessary repository files — a Git repository skeleton.
  • 25. Create a Remote Repository DevOps course by Abdul Rahim – Login to www.github.com – Click the + at the top right, – New Repository, – Enter Repository Name, Description, Chose Public and initialize with a README. – Click create repository – Your Repository will be created with following link github.com/<username>/<repo-name>
  • 26. Connect Local & Remote Repository DevOps course by Abdul Rahim – Open Git bash and Run the command git remote add origin https://github.com/<user-name>/<repo-name>.git – Push the file to the remote repository. git push origin master
  • 27. Cloning an Existing Repository DevOps course by Abdul Rahim – You can clone a repo, by clicking the code button, and copying the link. Go to git bash – Using https git clone https://github.com/<user-name>/<repo-name>.git – Using ssh git clone git@github.com:<user-name>/<repo-name>.git – Download Zip
  • 28. LAB - GIT Commands DevOps course by Abdul Rahim 1. Make changes to your project 2. Checking File Differences 3. Commit changes to your local repository 4. Resetting Differences
  • 29. LAB 5- Make changes to your project DevOps course by Abdul Rahim – Create a “hello.html” file in it with the following contents <h1>Hello, World!<h1> – Check the current state of the repository. git status – Meaning “hello.html” file is added that is currently untracked i.e. it is not present in git history
  • 30. LAB 6- Checking File Differences DevOps course by Abdul Rahim – Now let’s add the page to staging area of the repository. git add hello.html or git add . git status – It means file is in staging, but it should be committed to local repo.
  • 31. LAB 6- Checking File Differences DevOps course by Abdul Rahim – Now edit the README.md file, add a bit description like "This is a test repository" or anything else. – Check the working directory’s status. git status – It shows that new file “hello.html” is yet to be committed, and “README.md” has been modified but it needs to be staged for commit first.
  • 32. LAB 6- Checking File Differences DevOps course by Abdul Rahim – Now see the differences that have been made git diff – It shows that text with - sign was removed and + sign were added.
  • 33. LAB 6- Checking File Differences DevOps course by Abdul Rahim – Add “README.md” file to staging. And then check status git status – It shows that a new file “hello.html” has added and “README.md” file modified, but yet to be committed
  • 34. LAB 6- Checking File Differences DevOps course by Abdul Rahim – Check differences in staging area git diff –staged – It shows both the differences of README.md as well as a.txt.
  • 35. LAB 7- Commit changes to your local repository DevOps course by Abdul Rahim – Now we will commit the changes in the local repository git commit –m ‘first commit’ git status – It shows that your local branch is ahead of origin/master by 1 commit that we just did. The working tree is clean and there are no changes to record.
  • 36. LAB 8- Resetting Differences DevOps course by Abdul Rahim – Now we have two changes in a commit. We want to reset these differences. There are 3 possible options. 1. MIXED (Default Method) Remove the commit from local repo, and also remove changes from staging area 2. SOFT Remove the commit from local repo, but keep the files in staging area 3. HARD Remove the commit from local repo, and staging area and even change the local files.
  • 37. Method-1 Mixed (Default Method) DevOps course by Abdul Rahim  git reset –mixed HEAD^ – Notice changes have been removed from local repo as well as staging area. So we will need to add and commit files again.
  • 38. Method-2 Soft DevOps course by Abdul Rahim  git reset –soft HEAD^ – Notice that files are still in staging area but have been removed from local repo, now you will just need to commit them again.
  • 39. Method-3 Hard DevOps course by Abdul Rahim  git reset –hard HEAD^ – Notice the changes have been removed from local repo, as well as the working tree i.e. the files are now in initial state that was before your working.
  • 40. PUSH And PULL DevOps course by Abdul Rahim – PUSH – Transfer commits from your local repository to a remote repository. – Share modifications with remote team members. – Commands  git push origin
  • 41. PUSH And PULL DevOps course by Abdul Rahim – PULL – Download content from a remote repository and update the local repository – Get modification from remote team members – Commands  git pull origin
  • 42. LAB - PUSH And PULL DevOps course by Abdul Rahim 1. Push to Remote Repository 2. Pull from Remote Repository
  • 43. LAB 1- Push to Remote Repository DevOps course by Abdul Rahim – Let’s create the “hello.html” file in it with the following contents <h1>Hello, World!<h1> – Now add and commit the file – git add . – git commit –m ‘first commit’
  • 44. LAB 1- Push to Remote Repository DevOps course by Abdul Rahim – Your current changes are in the local repository to verify that go to Github and verify that “hello.html” does not exist. Push changes from local repository using the command: – git push origin master
  • 45. LAB 2- Pull from Remote Repository DevOps course by Abdul Rahim – You will create a file on Github and then pull those changes in your local repository – Go to your Github repository that you created and create new file.
  • 46. LAB 2- Pull from Remote Repository DevOps course by Abdul Rahim
  • 47. LAB 2- Pull from Remote Repository DevOps course by Abdul Rahim – Next you will pull the latest changes from remote to local repository
  • 48. Github Pages DevOps course by Abdul Rahim – GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website. – You can use GitHub Pages to host a website about yourself, your organization, or your project directly from a GitHub repository. – You get one site per GitHub account and organization, and unlimited project sites. – Does not support server side code such as PHP, Python or Ruby – GitHub Pages are publicly available on the internet, even if their repositories are private.
  • 49. ASSIGNMENT DevOps course by Abdul Rahim – HOST YOUR RESUME ON GITHUB PAGES – INSTRUCTIONS  Create your Resume Repository on GitHub  Host it through GitHub Pages
  • 50. Reference DevOps course by Abdul Rahim – https://git-scm.com/ – https://www.simplilearn.com/tutorials/git-tutorial/what-is-git – https://www.atlassian.com/git/tutorials/why-git – https://www.designveloper.com/blog/git-concepts-architecture/ – https://www.youtube.com/ – https://githowto.com/ – https://pages.github.com/ – https://docs.github.com/en/github/working-with-github-pages