Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Version Control
GIT Primer
AUG 2015
Saad Ulde
Version Control GIT
● The What
● The Why
● The How
● Popular Implementations
Conclusion
● Introduction
● Branching
● Insta...
What is Version Control?
Provides
● Create
● Save
● Edit/Modify
● Save AGAIN – This is where Version Control
comes in!
Dai...
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...
GIT
Introduction Terminologies
● GIT is an implementation of distributed style
Version Control
● Minimal efforts for setti...
Branching GIT | Branching
● Branches are used to develop separate and isolated features
● Master branch – The default bran...
Installation GIT | Installation
● All major platforms supported
● https://git-scm.com/download
● Configuring the username ...
Basic Commands GIT | Commands
● git init <project name> – initializes a new repository
● git status – Get a list of files ...
Gitlab GIT | Gitlab
● Introduction to Gitlab
● Walkthrough and different elements on the UI
● Issue tracking
● Wiki
● Merg...
Conflicts! GIT | Conflicts!
● Index.html is a existing file
● User 1 modifies the footer div in it and pushes the new chan...
Conflict Resolution GIT | Conflict Resolution
● Open the file that has the conflict in it, the conflicting section should ...
Caveats Conclusion | Caveats
● Peer-review
● Concise commit messages
● Link the bug number in the commit messages if it’s ...
Useful Commands Conclusion | Useful Commands
● Ever so often, it may happen that a commit needs to be reverted
● git rever...
Q&A
Thank You
Upcoming SlideShare
Loading in …5
×

Version control and GIT Primer

242 views

Published on

A dummy's guide to Version Control and a brief introduction to GIT and GIT commands.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Version control and GIT Primer

  1. 1. Version Control GIT Primer AUG 2015 Saad Ulde
  2. 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. 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. 4. History Tracking Version Control | History Tracking | Individual Individual Tracking
  5. 5. History Tracking Version Control | History Tracking | Collaboration Collaborative Tracking
  6. 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. 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. 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. 9. Installation GIT | Installation ● All major platforms supported ● https://git-scm.com/download ● Configuring the username and email ● Initializing a repository
  10. 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. 11. Gitlab GIT | Gitlab ● Introduction to Gitlab ● Walkthrough and different elements on the UI ● Issue tracking ● Wiki ● Merge requests ● Milestones ● Commits
  12. 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. 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. 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. 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. 16. Q&A
  17. 17. Thank You

×