SlideShare a Scribd company logo
Advanced Web Development in PHP
Module III: Code Versioning and
Branching with Git
Rasan Samarasinghe
ESOFT Computer Studies (pvt) Ltd.
No 68/1, Main Street, Embilipitiya.
Contents
1. Introduction to Git
2. What is Version Controlling?
3. What is Distributed Version Controlling?
4. Why Use a Version Control System?
5. Downloading and Installing Git
6. Git Life Cycle
7. Init command
8. Clone Command
9. Config Command
10. Add Command
11. Commit Command
12. Status Command
13. Log Command
14. Diff Command
15. Revert Command
16. Reset Command
17. Clean Command
18. Commit --amend Command
19. Rebase Command
20. Reflog Command
21. Branch Command
22. Checkout Command
23. Merge Command
24. Remote Command
25. Fetch Command
26. Pull Command
27. Push Command
Introduction to Git
Git is a distributed version control system, allows
group of people to work on same source code at
the same time without stepping on each others
toes.
What is Version Controlling?
Version control is a system that records changes to
a file or set of files over time so that you can recall
specific versions later.
What is Distributed Version Controlling?
Distributed version control allows many software
developers to work on a given project without
requiring them to share a common network.
Why Use a Version Control System?
โ€ข Collaboration
โ€ข Storing Versions
โ€ข Restoring Previous Versions
โ€ข Understanding What Happened
โ€ข Backup
Downloading and Installing Git
https://git-scm.com
Git Life Cycle
1. You clone the GIT repository as a working copy.
2. You modify the working copy by adding/editing files.
3. If necessary, you also update the working copy by taking other
developer's changes.
4. You review the changes before commit.
5. You commit changes. If everything is fine, then you push the changes
to the repository.
6. After committing, if you realize something is wrong, then you correct
the last commit and push the changes to the repository.
Git Life Cycle
Git Basics
Init Command
git init <directory>
Create empty Git repo in specified directory. Run
with no arguments to initialize the current directory
as a git repository.
Clone Command
git clone <repository URL>
Clone repo located at onto local machine. Original
repo can be located on the local file system or on a
remote machine via HTTP or SSH.
Config Command
git config user.name <name>
git config user.email <email>
Define author name to be used for all commits in
current repo. Developers commonly use --global
flag to set config options for current user.
Add Command
git add <directory>
Stage all changes in for the next commit. Replace
<directory> with a to change a specific file.
Commit Command
git commit -m โ€œ<message>โ€œ
Commit the staged snapshot, but instead of
launching a text editor, use <message> as the
commit message.
Status Command
git status
List which files are staged, unstaged, and untracked.
Log Command
git log
Display the entire commit history using the default
format. For customization see additional options.
Diff Command
git diff
Show unstaged changes between your index and
working directory
Diff Command
git diff โ€“cached
Show difference between staged changes and last
commit.
Diff Command
git diff <commit 1> <commit 2>
What changed between $ <commit 1> and <commit
2>
Undoing Changes
Revert Command
git revert <commit>
Create new commit that undoes all of the changes
made in <commit>, then apply it to the current
branch.
Reset Command
git reset <file>
Remove <file> from the staging area, but leave the
working directory unchanged. This unstages a file
without overwriting any changes.
Reset Command
git reset
Reset staging area to match most recent commit,
but leave the working directory unchanged.
Reset Command
git reset --hard
Reset staging area and working directory to match
most recent commit and overwrites all changes in
the working directory.
Reset Command
git reset <commit>
Move the current branch tip backward to
<commit>, reset the staging area to match, but
leave the working directory alone.
Reset Command
git reset --hard <commit>
Same as previous, but resets both the staging area
& working directory to match. Deletes
uncommitted changes, and all commits after
<commit>.
Clean Command
git clean โ€“n
Shows which files would be removed (untracked
files) from working directory. Use the -f flag in place
of the -n flag to execute the clean.
Rewriting Git History
Commit --amend Command
git commit โ€“-amend
Replace the last commit with the staged changes
and last commit combined. Use with nothing staged
to edit the last commitโ€™s message.
Rebase Command
git rebase <base>
Rebase the current branch onto <base>. <base> can
be a commitID, a branch name, a tag, or a relative
reference to HEAD
Reflog Command
git reflog
Show a log of changes to the local repository's
HEAD. Add โ€“relativedate flag to show date info or --
all to show all refs.
Git Branches
Branch Command
git branch
List all of the branches in your repo. Add a <branch>
argument to create a new branch with the name
<branch>
Checkout Command
git checkout -b <branch>
Create and check out a new branch named
<branch>. Drop the -b flag to checkout an existing
branch.
Merge Command
git merge <branch>
Merge <branch> into the current branch.
Remote Repositories
Remote Command
git remote add <name> <url>
Create a new connection to a remote repo. After
adding a remote, you can use <name> as a shortcut
for <url> in other commands.
Fetch Command
git fetch <remote> <branch>
Fetches a specific <branch>, from the repo. Leave
off <branch> to fetch all remote refs.
Pull Command
git pull <remote>
Fetch the specified remoteโ€™s copy of current branch
and immediately merge it into the local copy.
Push Command
git push <remote> <branch>
Push the branch to <remote>, along with necessary
commits and objects. Creates named branch in the
remote repo if it doesnโ€™t exist.
The End
http://twitter.com/rasansmn

More Related Content

What's hot (19)

PDF
Git ๅ…ฅ้—จไธŽๅฎž่ทต
Terry Wang
ย 
PDF
Tร i liแป‡u sแปญ dแปฅng GitHub
viet nghiem
ย 
PPTX
GDSC - Introduction to GIT
ViktorKatzenberger
ย 
PDF
GIT Basics
Tagged Social
ย 
PPTX
Git
Hanokh Aloni
ย 
PPTX
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
ย 
PDF
GIT_In_90_Minutes
vimukthirandika
ย 
PDF
Version Control with Git
Luigi De Russis
ย 
PPTX
Git Basic
Luke Luo
ย 
PPTX
Git presentation, Viktor Pyskunov
Viktor Pyskunov
ย 
PPTX
Linux GIT commands
RajKumar Rampelli
ย 
PDF
Github git-cheat-sheet
Augusto Gabriel Luna Bardales
ย 
PDF
Subversion to Git Migration
Tim Massey
ย 
PDF
Learn Git Fundamentals
Jatin Sharma
ย 
PPT
Introducciรณn a Git
Juan Antonio
ย 
PDF
Git (Sistema Distribuido de Control de Versiones)
TAWS
ย 
ODP
Git vs svn
Suman Mukherjee
ย 
Git ๅ…ฅ้—จไธŽๅฎž่ทต
Terry Wang
ย 
Tร i liแป‡u sแปญ dแปฅng GitHub
viet nghiem
ย 
GDSC - Introduction to GIT
ViktorKatzenberger
ย 
GIT Basics
Tagged Social
ย 
Git
Hanokh Aloni
ย 
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
ย 
GIT_In_90_Minutes
vimukthirandika
ย 
Version Control with Git
Luigi De Russis
ย 
Git Basic
Luke Luo
ย 
Git presentation, Viktor Pyskunov
Viktor Pyskunov
ย 
Linux GIT commands
RajKumar Rampelli
ย 
Github git-cheat-sheet
Augusto Gabriel Luna Bardales
ย 
Subversion to Git Migration
Tim Massey
ย 
Learn Git Fundamentals
Jatin Sharma
ย 
Introducciรณn a Git
Juan Antonio
ย 
Git (Sistema Distribuido de Control de Versiones)
TAWS
ย 
Git vs svn
Suman Mukherjee
ย 

Similar to Advanced Web Development in PHP - Code Versioning and Branching with Git (20)

PDF
Collaborative development with Git | Workshop
Anuchit Chalothorn
ย 
PPTX
Git hub abduallah abu nada
Lama K Banna
ย 
PPTX
Git
Mouad EL Fakir
ย 
PDF
Git training v10
Skander Hamza
ย 
PPTX
An introduction to Git
Muhil Vannan
ย 
PPTX
Git - Basic Crash Course
Nilay Binjola
ย 
PDF
Version control and GIT Primer
saadulde
ย 
PDF
Atlassian git cheatsheet
Abdul Basit
ย 
PPTX
Git Memento of basic commands
Zakaria Bouazza
ย 
PPTX
Git and Github
Teodora Ahkozidou
ย 
PPTX
Git 101 - An introduction to Version Control using Git
John Tighe
ย 
PDF
Git and github 101
Senthilkumar Gopal
ย 
PPTX
Git and github
Teodora Ahkozidou
ย 
PPTX
Version controll.pptx
Md. Main Uddin Rony
ย 
PPTX
Hacktoberfest intro to Git and GitHub
DSC GVP
ย 
PDF
Git of every day
Alan Descoins
ย 
PPTX
Git commands
Viyaan Jhiingade
ย 
KEY
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
ย 
PPTX
GIT.pptx
Soumen Debgupta
ย 
PPTX
Bitbucket as a code server and pmt
malike4u
ย 
Collaborative development with Git | Workshop
Anuchit Chalothorn
ย 
Git hub abduallah abu nada
Lama K Banna
ย 
Git training v10
Skander Hamza
ย 
An introduction to Git
Muhil Vannan
ย 
Git - Basic Crash Course
Nilay Binjola
ย 
Version control and GIT Primer
saadulde
ย 
Atlassian git cheatsheet
Abdul Basit
ย 
Git Memento of basic commands
Zakaria Bouazza
ย 
Git and Github
Teodora Ahkozidou
ย 
Git 101 - An introduction to Version Control using Git
John Tighe
ย 
Git and github 101
Senthilkumar Gopal
ย 
Git and github
Teodora Ahkozidou
ย 
Version controll.pptx
Md. Main Uddin Rony
ย 
Hacktoberfest intro to Git and GitHub
DSC GVP
ย 
Git of every day
Alan Descoins
ย 
Git commands
Viyaan Jhiingade
ย 
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
ย 
GIT.pptx
Soumen Debgupta
ย 
Bitbucket as a code server and pmt
malike4u
ย 
Ad

More from Rasan Samarasinghe (20)

PPTX
Managing the under performance in projects.pptx
Rasan Samarasinghe
ย 
PPTX
Agile project management with scrum
Rasan Samarasinghe
ย 
PPTX
Introduction to Agile
Rasan Samarasinghe
ย 
PPSX
IT Introduction (en)
Rasan Samarasinghe
ย 
PPSX
Application of Unified Modelling Language
Rasan Samarasinghe
ย 
PPSX
Advanced Web Development in PHP - Understanding REST API
Rasan Samarasinghe
ย 
PPSX
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
ย 
PPSX
DIWE - Working with MySQL Databases
Rasan Samarasinghe
ย 
PPSX
DIWE - Using Extensions and Image Manipulation
Rasan Samarasinghe
ย 
PPSX
DIWE - File handling with PHP
Rasan Samarasinghe
ย 
PPSX
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
ย 
PPSX
DIWE - Fundamentals of PHP
Rasan Samarasinghe
ย 
PPSX
DIWE - Programming with JavaScript
Rasan Samarasinghe
ย 
PPSX
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
ย 
PPSX
DIWE - Multimedia Technologies
Rasan Samarasinghe
ย 
PPSX
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
ย 
PPSX
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
ย 
PPSX
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
ย 
PPSX
DISE - Software Testing and Quality Management
Rasan Samarasinghe
ย 
PPSX
DISE - Introduction to Project Management
Rasan Samarasinghe
ย 
Managing the under performance in projects.pptx
Rasan Samarasinghe
ย 
Agile project management with scrum
Rasan Samarasinghe
ย 
Introduction to Agile
Rasan Samarasinghe
ย 
IT Introduction (en)
Rasan Samarasinghe
ย 
Application of Unified Modelling Language
Rasan Samarasinghe
ย 
Advanced Web Development in PHP - Understanding REST API
Rasan Samarasinghe
ย 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
ย 
DIWE - Working with MySQL Databases
Rasan Samarasinghe
ย 
DIWE - Using Extensions and Image Manipulation
Rasan Samarasinghe
ย 
DIWE - File handling with PHP
Rasan Samarasinghe
ย 
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
ย 
DIWE - Fundamentals of PHP
Rasan Samarasinghe
ย 
DIWE - Programming with JavaScript
Rasan Samarasinghe
ย 
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
ย 
DIWE - Multimedia Technologies
Rasan Samarasinghe
ย 
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
ย 
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
ย 
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
ย 
DISE - Software Testing and Quality Management
Rasan Samarasinghe
ย 
DISE - Introduction to Project Management
Rasan Samarasinghe
ย 
Ad

Recently uploaded (20)

PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
ย 
PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
ย 
PPTX
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
ย 
PPTX
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
ย 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
PPTX
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
ย 
PDF
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
ย 
PPTX
For my supp to finally picking supp that work
necas19388
ย 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
ย 
PDF
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
PDF
>Wondershare Filmora Crack Free Download 2025
utfefguu
ย 
PDF
AI Software Development Process, Strategies and Challenges
Net-Craft.com
ย 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
ย 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
PPTX
Introduction to web development | MERN Stack
JosephLiyon
ย 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
ย 
PDF
Rewards and Recognition (2).pdf
ethan Talor
ย 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
ย 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
ย 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
ย 
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
ย 
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
ย 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
ย 
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
ย 
For my supp to finally picking supp that work
necas19388
ย 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
ย 
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
>Wondershare Filmora Crack Free Download 2025
utfefguu
ย 
AI Software Development Process, Strategies and Challenges
Net-Craft.com
ย 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
ย 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
Introduction to web development | MERN Stack
JosephLiyon
ย 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
ย 
Rewards and Recognition (2).pdf
ethan Talor
ย 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
ย 

Advanced Web Development in PHP - Code Versioning and Branching with Git

  • 1. Advanced Web Development in PHP Module III: Code Versioning and Branching with Git Rasan Samarasinghe ESOFT Computer Studies (pvt) Ltd. No 68/1, Main Street, Embilipitiya.
  • 2. Contents 1. Introduction to Git 2. What is Version Controlling? 3. What is Distributed Version Controlling? 4. Why Use a Version Control System? 5. Downloading and Installing Git 6. Git Life Cycle 7. Init command 8. Clone Command 9. Config Command 10. Add Command 11. Commit Command 12. Status Command 13. Log Command 14. Diff Command 15. Revert Command 16. Reset Command 17. Clean Command 18. Commit --amend Command 19. Rebase Command 20. Reflog Command 21. Branch Command 22. Checkout Command 23. Merge Command 24. Remote Command 25. Fetch Command 26. Pull Command 27. Push Command
  • 3. Introduction to Git Git is a distributed version control system, allows group of people to work on same source code at the same time without stepping on each others toes.
  • 4. What is Version Controlling? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
  • 5. What is Distributed Version Controlling? Distributed version control allows many software developers to work on a given project without requiring them to share a common network.
  • 6. Why Use a Version Control System? โ€ข Collaboration โ€ข Storing Versions โ€ข Restoring Previous Versions โ€ข Understanding What Happened โ€ข Backup
  • 7. Downloading and Installing Git https://git-scm.com
  • 8. Git Life Cycle 1. You clone the GIT repository as a working copy. 2. You modify the working copy by adding/editing files. 3. If necessary, you also update the working copy by taking other developer's changes. 4. You review the changes before commit. 5. You commit changes. If everything is fine, then you push the changes to the repository. 6. After committing, if you realize something is wrong, then you correct the last commit and push the changes to the repository.
  • 11. Init Command git init <directory> Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository.
  • 12. Clone Command git clone <repository URL> Clone repo located at onto local machine. Original repo can be located on the local file system or on a remote machine via HTTP or SSH.
  • 13. Config Command git config user.name <name> git config user.email <email> Define author name to be used for all commits in current repo. Developers commonly use --global flag to set config options for current user.
  • 14. Add Command git add <directory> Stage all changes in for the next commit. Replace <directory> with a to change a specific file.
  • 15. Commit Command git commit -m โ€œ<message>โ€œ Commit the staged snapshot, but instead of launching a text editor, use <message> as the commit message.
  • 16. Status Command git status List which files are staged, unstaged, and untracked.
  • 17. Log Command git log Display the entire commit history using the default format. For customization see additional options.
  • 18. Diff Command git diff Show unstaged changes between your index and working directory
  • 19. Diff Command git diff โ€“cached Show difference between staged changes and last commit.
  • 20. Diff Command git diff <commit 1> <commit 2> What changed between $ <commit 1> and <commit 2>
  • 22. Revert Command git revert <commit> Create new commit that undoes all of the changes made in <commit>, then apply it to the current branch.
  • 23. Reset Command git reset <file> Remove <file> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.
  • 24. Reset Command git reset Reset staging area to match most recent commit, but leave the working directory unchanged.
  • 25. Reset Command git reset --hard Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory.
  • 26. Reset Command git reset <commit> Move the current branch tip backward to <commit>, reset the staging area to match, but leave the working directory alone.
  • 27. Reset Command git reset --hard <commit> Same as previous, but resets both the staging area & working directory to match. Deletes uncommitted changes, and all commits after <commit>.
  • 28. Clean Command git clean โ€“n Shows which files would be removed (untracked files) from working directory. Use the -f flag in place of the -n flag to execute the clean.
  • 30. Commit --amend Command git commit โ€“-amend Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commitโ€™s message.
  • 31. Rebase Command git rebase <base> Rebase the current branch onto <base>. <base> can be a commitID, a branch name, a tag, or a relative reference to HEAD
  • 32. Reflog Command git reflog Show a log of changes to the local repository's HEAD. Add โ€“relativedate flag to show date info or -- all to show all refs.
  • 34. Branch Command git branch List all of the branches in your repo. Add a <branch> argument to create a new branch with the name <branch>
  • 35. Checkout Command git checkout -b <branch> Create and check out a new branch named <branch>. Drop the -b flag to checkout an existing branch.
  • 36. Merge Command git merge <branch> Merge <branch> into the current branch.
  • 38. Remote Command git remote add <name> <url> Create a new connection to a remote repo. After adding a remote, you can use <name> as a shortcut for <url> in other commands.
  • 39. Fetch Command git fetch <remote> <branch> Fetches a specific <branch>, from the repo. Leave off <branch> to fetch all remote refs.
  • 40. Pull Command git pull <remote> Fetch the specified remoteโ€™s copy of current branch and immediately merge it into the local copy.
  • 41. Push Command git push <remote> <branch> Push the branch to <remote>, along with necessary commits and objects. Creates named branch in the remote repo if it doesnโ€™t exist.