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

PDF
Version Control Systems with git (and github) as an example
PPTX
Git learn from scratch
PDF
Mac Linux Commands cheatsheet
PDF
Git in 5 Minutes
PPTX
Intro to Git DevOps Tally Presentation 101615
PPTX
From svn to git
PDF
HackMTY - GitHub Workshop
PDF
SVN 2 Git
Version Control Systems with git (and github) as an example
Git learn from scratch
Mac Linux Commands cheatsheet
Git in 5 Minutes
Intro to Git DevOps Tally Presentation 101615
From svn to git
HackMTY - GitHub Workshop
SVN 2 Git

What's hot (19)

PDF
Git 入门与实践
PDF
Tài liệu sử dụng GitHub
PPTX
GDSC - Introduction to GIT
PDF
GIT Basics
PPTX
PPTX
Advanced Git Presentation By Swawibe
PDF
GIT_In_90_Minutes
PDF
Version Control with Git
PPTX
Git Basic
PPTX
Git presentation, Viktor Pyskunov
PPTX
Linux GIT commands
PDF
Github git-cheat-sheet
PDF
Subversion to Git Migration
PDF
Learn Git Fundamentals
PPT
Introducción a Git
PDF
Git (Sistema Distribuido de Control de Versiones)
ODP
Git vs svn
Git 入门与实践
Tài liệu sử dụng GitHub
GDSC - Introduction to GIT
GIT Basics
Advanced Git Presentation By Swawibe
GIT_In_90_Minutes
Version Control with Git
Git Basic
Git presentation, Viktor Pyskunov
Linux GIT commands
Github git-cheat-sheet
Subversion to Git Migration
Learn Git Fundamentals
Introducción a Git
Git (Sistema Distribuido de Control de Versiones)
Git vs svn
Ad

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

PDF
Collaborative development with Git | Workshop
PPTX
Git hub abduallah abu nada
PDF
Git training v10
PPTX
An introduction to Git
PPTX
Git - Basic Crash Course
PDF
Version control and GIT Primer
PDF
Atlassian git cheatsheet
PPTX
Git Memento of basic commands
PPTX
Git and Github
PPTX
Git 101 - An introduction to Version Control using Git
PDF
Git and github 101
PPTX
Git and github
PPTX
Version controll.pptx
PPTX
Hacktoberfest intro to Git and GitHub
PDF
Git of every day
PPTX
Git commands
KEY
Let's Git this Party Started: An Introduction to Git and GitHub
PPTX
GIT.pptx
PPTX
Bitbucket as a code server and pmt
Collaborative development with Git | Workshop
Git hub abduallah abu nada
Git training v10
An introduction to Git
Git - Basic Crash Course
Version control and GIT Primer
Atlassian git cheatsheet
Git Memento of basic commands
Git and Github
Git 101 - An introduction to Version Control using Git
Git and github 101
Git and github
Version controll.pptx
Hacktoberfest intro to Git and GitHub
Git of every day
Git commands
Let's Git this Party Started: An Introduction to Git and GitHub
GIT.pptx
Bitbucket as a code server and pmt
Ad

More from Rasan Samarasinghe (20)

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

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Transform Your Business with a Software ERP System
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
L1 - Introduction to python Backend.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPT
Introduction Database Management System for Course Database
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
System and Network Administration Chapter 2
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
ManageIQ - Sprint 268 Review - Slide Deck
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Wondershare Filmora 15 Crack With Activation Key [2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Transform Your Business with a Software ERP System
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
How to Migrate SBCGlobal Email to Yahoo Easily
VVF-Customer-Presentation2025-Ver1.9.pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
L1 - Introduction to python Backend.pptx
CHAPTER 2 - PM Management and IT Context
Introduction Database Management System for Course Database
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Odoo POS Development Services by CandidRoot Solutions
System and Network Administration Chapter 2
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms I-SECS-1021-03

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.