SlideShare ist ein Scribd-Unternehmen logo
1 von 17
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 DevelopersMartin Jinoch
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim 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-flowMd. Masud
 
Git learn from scratch
Git learn from scratchGit learn from scratch
Git learn from scratchMir Arif Hasan
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucketazwildcat
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Version Control System
Version Control SystemVersion Control System
Version Control Systemguptaanil
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - GitCarlo Bernaschina
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git MigrationTim Massey
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitLuigi De Russis
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git BasicsSreedath N S
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 

Was ist angesagt? (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 入门与实践
 

Ähnlich wie 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, TrivandrumAbhijitNarayan2
 
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 GitDivineOmega
 
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 padawanJames 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 workAlena Radkevich
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentalsRajKharvar
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone useIkuru Kanuma
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitAmit Mathur
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!Cory Webb
 

Ähnlich wie 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
 
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
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!
 

Kürzlich hochgeladen

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Kürzlich hochgeladen (20)

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

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