SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 

Mais procurados (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 入门与实践
 

Semelhante a Version control and GIT Primer

Semelhante a 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!
 

Último

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
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
 

Último (20)

Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
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...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
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
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
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
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
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, ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

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