SlideShare a Scribd company logo
1 of 42
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)

Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHub
 
GDSC - Introduction to GIT
GDSC - Introduction to GITGDSC - Introduction to GIT
GDSC - Introduction to GIT
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Git
GitGit
Git
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Git Basic
Git BasicGit Basic
Git Basic
 
Git presentation, Viktor Pyskunov
Git presentation, Viktor PyskunovGit presentation, Viktor Pyskunov
Git presentation, Viktor Pyskunov
 
Git
GitGit
Git
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
 
Git
GitGit
Git
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Learn Git Fundamentals
Learn Git FundamentalsLearn Git Fundamentals
Learn Git Fundamentals
 
Introducción a Git
Introducción a GitIntroducción a Git
Introducción a Git
 
Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)Git (Sistema Distribuido de Control de Versiones)
Git (Sistema Distribuido de Control de Versiones)
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 

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

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

Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git github
Git githubGit github
Git github
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git and github
Git and githubGit and github
Git and github
 
Git introduction
Git introductionGit introduction
Git introduction
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Git&GitHub.pptx
Git&GitHub.pptxGit&GitHub.pptx
Git&GitHub.pptx
 
github_gyan.pptx
github_gyan.pptxgithub_gyan.pptx
github_gyan.pptx
 
Git
GitGit
Git
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 

More from Rasan Samarasinghe

Managing the under performance in projects.pptx
Managing the under performance in projects.pptxManaging the under performance in projects.pptx
Managing the under performance in projects.pptxRasan Samarasinghe
 
Agile project management with scrum
Agile project management with scrumAgile project management with scrum
Agile project management with scrumRasan Samarasinghe
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling LanguageRasan Samarasinghe
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Rasan Samarasinghe
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesRasan Samarasinghe
 
DIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationDIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationRasan Samarasinghe
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScriptRasan Samarasinghe
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningRasan Samarasinghe
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesRasan Samarasinghe
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsRasan Samarasinghe
 
DISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementDISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementRasan Samarasinghe
 
DISE - Introduction to Project Management
DISE - Introduction to Project ManagementDISE - Introduction to Project Management
DISE - Introduction to Project ManagementRasan Samarasinghe
 

More from Rasan Samarasinghe (20)

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

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 

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.