SlideShare a Scribd company logo
Version Control
GIT Primer
AUG 2015
Saad Ulde
Version Control GIT
● The What
● The Why
● The How
● Popular Implementations
Conclusion
● Introduction
● Branching
● Installation
● Commands
● Gitlab
● Demo and Hands-on
● Conflicts!
● Conflict Resolution
● Caveats
● Useful commands
● Q&A
Outline
What is Version Control?
Provides
● Create
● Save
● Edit/Modify
● Save AGAIN – This is where Version Control
comes in!
Daily Tasks for a Developer
● When was the change made?
● Why was it made?
● What the changes were?
● Who did it?
History Tracking Version Control | History Tracking | Individual
Individual Tracking
History Tracking Version Control | History Tracking | Collaboration
Collaborative Tracking
Popular Implementations Version Control | Popular Implementations
Distributed Centralized
● Peer-to-peer approach
● Entire copy of the codebase is replicated
● Changes go in the local repository first, and if
need be, shared with others
● Platforms - GIT, Mercurial, Bazaar etc.
● Software's – Gitlab, GitHub, Bitbucket etc.
● Client-server approach
● Only the server has the entire copy
● Changes go directly to the central repository
● Collaborators see the change immediately
● Platforms – SVN, ClearCase etc.
● Software's – TortoiseSVN, SmartSVN etc.
GIT
Introduction Terminologies
● GIT is an implementation of distributed style
Version Control
● Minimal efforts for setting up
● Highly customizable
● Can be installed locally (on a single computer)
or on a server (on a network)
● Developers can use CLI, desktop applications
or web application to see the see their
repositories
● Working directory – Actual files that you are
working on
● Index – Staging area
● HEAD – points to the last commit you did
● Remote repository – The main or the central
copy of the repository
● Local repository – The local version of the
central repository
Branching GIT | Branching
● Branches are used to develop separate and isolated features
● Master branch – The default branch when you create a
repository
● You can create (split) branches from any branch
● You can merge it back to the parent branch once the
development is over
Installation GIT | Installation
● All major platforms supported
● https://git-scm.com/download
● Configuring the username and email
● Initializing a repository
Basic Commands GIT | Commands
● git init <project name> – initializes a new repository
● git status – Get a list of files modified on locally
● git add <file name> – Adds the file to the staging area
● git commit -m “<message>” – Commits all the files that were added to the staging area
● git diff <file name> – Lists the changes made to the file when compared to the HEAD version
● git checkout <file name> – Restores the file with the HEAD version
● git checkout [-b] <branch name> – Switches the branch, the –b parameter will create a new branch
● git stash – Backups up any local changes made
● git stash apply – Restores the most recent backed up files
● git pull – Pulls the latest changes from the repository
● git reset HEAD – Removes all the local changes made to the files that are already in the repository
● git reset [-–hard] HEAD <file name> – Will unstage all the file if it was staged else it will remove all the local changes
made to the file
● git push origin <branch name> - Pushes the changes in the local repository to the remote repository
● git rm <file name> - will remove the file from the working area and the stage the removed file
Gitlab GIT | Gitlab
● Introduction to Gitlab
● Walkthrough and different elements on the UI
● Issue tracking
● Wiki
● Merge requests
● Milestones
● Commits
Conflicts! GIT | Conflicts!
● Index.html is a existing file
● User 1 modifies the footer div in it and pushes the new changes
● User 2 is simultaneously modifying the footer section of the same file, once he is done with his changes he takes a pull
● User 2 does a stash apply, git prompt will throw an error since they both were working on the same section of the same file
Scenario
Conflict Resolution GIT | Conflict Resolution
● Open the file that has the conflict in it, the conflicting section should look similar to this -
● The lines between <<<< and ==== indicate the changes done in the remote branch, and the lines between ==== and >>>> indicate
your changes
● Once you decide which part you want to keep you can delete those 3 lines
● Follow this by either git reset HEAD <file name> or git add<file name> depending on whether you want to stage the
file or not
● Voila! Conflict resolved!
Caveats Conclusion | Caveats
● Peer-review
● Concise commit messages
● Link the bug number in the commit messages if it’s a bug fix
● Push stable and error free code
● If the commit is a partial feature, then make sure you are mentioning it in the commit message
Useful Commands Conclusion | Useful Commands
● Ever so often, it may happen that a commit needs to be reverted
● git revert <commit id> - Reverts the commit with the commit id mentioned, and prepare a commit with the reverted changes
● git cherry-pick <commit id> - Specifically pull the commit from other branch and add it to the current local branch and
stage the changes
Q&A
Thank You

More Related Content

What's hot

Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
Martin Jinoch
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
Cristian Lucchesi
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
Leonid Mamchenkov
 
Gitt and Git-flow
Gitt and Git-flowGitt and Git-flow
Gitt and Git-flow
Md. Masud
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
Haitham Raik
 
Git learn from scratch
Git learn from scratchGit learn from scratch
Git learn from scratch
Mir Arif Hasan
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucketazwildcat
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
Jason Byrne
 
Version Control System
Version Control SystemVersion Control System
Version Control System
guptaanil
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
Carlo Bernaschina
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
Tim Massey
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
Sreedath N S
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 

What's hot (19)

Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
 
Git introduction
Git introductionGit introduction
Git introduction
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 
Gitt and Git-flow
Gitt and Git-flowGitt and Git-flow
Gitt and Git-flow
 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
 
Git learn from scratch
Git learn from scratchGit learn from scratch
Git learn from scratch
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Version Control System
Version Control SystemVersion Control System
Version Control System
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 

Similar to Version control and GIT Primer

Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
AbhijitNarayan2
 
GIT
GITGIT
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
James Ford
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
Alena Radkevich
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
Soumen Debgupta
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
RajKharvar
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone use
Ikuru Kanuma
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
Edward Goikhman
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Amit Mathur
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
Mithilesh Singh
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
Priyanka Nag
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 

Similar to Version control and GIT Primer (20)

Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
 
GIT
GITGIT
GIT
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone use
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
 
Git basics
Git basicsGit basics
Git basics
 

Recently uploaded

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 

Recently uploaded (20)

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 

Version control and GIT Primer

  • 2. Version Control GIT ● The What ● The Why ● The How ● Popular Implementations Conclusion ● Introduction ● Branching ● Installation ● Commands ● Gitlab ● Demo and Hands-on ● Conflicts! ● Conflict Resolution ● Caveats ● Useful commands ● Q&A Outline
  • 3. What is Version Control? Provides ● Create ● Save ● Edit/Modify ● Save AGAIN – This is where Version Control comes in! Daily Tasks for a Developer ● When was the change made? ● Why was it made? ● What the changes were? ● Who did it?
  • 4. History Tracking Version Control | History Tracking | Individual Individual Tracking
  • 5. History Tracking Version Control | History Tracking | Collaboration Collaborative Tracking
  • 6. Popular Implementations Version Control | Popular Implementations Distributed Centralized ● Peer-to-peer approach ● Entire copy of the codebase is replicated ● Changes go in the local repository first, and if need be, shared with others ● Platforms - GIT, Mercurial, Bazaar etc. ● Software's – Gitlab, GitHub, Bitbucket etc. ● Client-server approach ● Only the server has the entire copy ● Changes go directly to the central repository ● Collaborators see the change immediately ● Platforms – SVN, ClearCase etc. ● Software's – TortoiseSVN, SmartSVN etc.
  • 7. GIT Introduction Terminologies ● GIT is an implementation of distributed style Version Control ● Minimal efforts for setting up ● Highly customizable ● Can be installed locally (on a single computer) or on a server (on a network) ● Developers can use CLI, desktop applications or web application to see the see their repositories ● Working directory – Actual files that you are working on ● Index – Staging area ● HEAD – points to the last commit you did ● Remote repository – The main or the central copy of the repository ● Local repository – The local version of the central repository
  • 8. Branching GIT | Branching ● Branches are used to develop separate and isolated features ● Master branch – The default branch when you create a repository ● You can create (split) branches from any branch ● You can merge it back to the parent branch once the development is over
  • 9. Installation GIT | Installation ● All major platforms supported ● https://git-scm.com/download ● Configuring the username and email ● Initializing a repository
  • 10. Basic Commands GIT | Commands ● git init <project name> – initializes a new repository ● git status – Get a list of files modified on locally ● git add <file name> – Adds the file to the staging area ● git commit -m “<message>” – Commits all the files that were added to the staging area ● git diff <file name> – Lists the changes made to the file when compared to the HEAD version ● git checkout <file name> – Restores the file with the HEAD version ● git checkout [-b] <branch name> – Switches the branch, the –b parameter will create a new branch ● git stash – Backups up any local changes made ● git stash apply – Restores the most recent backed up files ● git pull – Pulls the latest changes from the repository ● git reset HEAD – Removes all the local changes made to the files that are already in the repository ● git reset [-–hard] HEAD <file name> – Will unstage all the file if it was staged else it will remove all the local changes made to the file ● git push origin <branch name> - Pushes the changes in the local repository to the remote repository ● git rm <file name> - will remove the file from the working area and the stage the removed file
  • 11. Gitlab GIT | Gitlab ● Introduction to Gitlab ● Walkthrough and different elements on the UI ● Issue tracking ● Wiki ● Merge requests ● Milestones ● Commits
  • 12. Conflicts! GIT | Conflicts! ● Index.html is a existing file ● User 1 modifies the footer div in it and pushes the new changes ● User 2 is simultaneously modifying the footer section of the same file, once he is done with his changes he takes a pull ● User 2 does a stash apply, git prompt will throw an error since they both were working on the same section of the same file Scenario
  • 13. Conflict Resolution GIT | Conflict Resolution ● Open the file that has the conflict in it, the conflicting section should look similar to this - ● The lines between <<<< and ==== indicate the changes done in the remote branch, and the lines between ==== and >>>> indicate your changes ● Once you decide which part you want to keep you can delete those 3 lines ● Follow this by either git reset HEAD <file name> or git add<file name> depending on whether you want to stage the file or not ● Voila! Conflict resolved!
  • 14. Caveats Conclusion | Caveats ● Peer-review ● Concise commit messages ● Link the bug number in the commit messages if it’s a bug fix ● Push stable and error free code ● If the commit is a partial feature, then make sure you are mentioning it in the commit message
  • 15. Useful Commands Conclusion | Useful Commands ● Ever so often, it may happen that a commit needs to be reverted ● git revert <commit id> - Reverts the commit with the commit id mentioned, and prepare a commit with the reverted changes ● git cherry-pick <commit id> - Specifically pull the commit from other branch and add it to the current local branch and stage the changes
  • 16. Q&A