Git Basics
Telerik Academy Alpha

 

 Table of contents

What is Version Control

Version Control System

  • 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

  • Allows you to revert files back to a previous state
     

  • Revert the entire project back to a previous state
     

  • Compare changes over time
     

  • See who last modified something that might be causing a problem
     

Local Version Control

  •  Local VCSs that had a simple database that kept all the changes to files under revision control

Centralized Version Control

  •  Single server that contains all the versioned files, and a number of clients that check out files from that central place

    • ​CVS

    • TFS

    • Subversion

Distributed Version Control

  • Clients don’t just check out the latest snapshot of the files: they fully mirror the repository

    • ​Git

    • Mercurial

    • Bazaar

What is Git

Git

  • The most widely used modern version control system in the world

    • ​originally developed in 2005 by Linus Torvalds (creator of Linux)

  • Every developer has a working copy of the code

    • repository that can contain the full history of all changes

  • ​Performance, security and flexibility in mind

1. PROS

Git

  • It could be difficult to learn for newcomers, especially coming from SVN

  • Many commands with many options

  • Some commands are non-intuitive and need a level of understanding the internals of git

2. CONS

Git branches

  • Feature branches
    • Git branches are cheap and easy to merge
    • Provide an isolated environment for every change
    • Branches ensures that the master branch always contains production-quality code

Distributed development

  • Each developer gets their own local repository
    • complete with a full history of commits
  • Distributed development creates a more reliable environment
  • In case of an error in central repository everybody can continue going about their business in their own local repositories

Pull request

  • A pull request is a way to ask another developer to merge one of your branches into their repository
    • ​Makes it easier for to keep track of changes
    • Lets developers initiate discussions around their work before integrating it with the rest of the codebase

Git Install

 Git Install

  • Install Git for your platform
  • Follow the instructions and setup Git
    • ​Use the default options for now
       
  • Git will be added in your PATH
     
  • Git Bash will be installed for you

 Check for Git installed

  • Open the command prompt or Git Bash
    • ​type "git --version"
  • This will ensure you have Git installed on your system
     
  • Now you are ready to begin using Git

Basic Git Commands

 Configure Git

  •  git config --global user.name "[name]"
    • ​Sets the user name for all commits
       
  • git config --global user.email "[email address]"
    • Sets the email for all commits

 Create/Clone repository

  •  git init [project name]
    • ​Creates new repository with specified name
       
  • git clone [repository url]
    • Downloads the specified repository

 Make/Check local changes

  •  git status
    • ​Lists all the changes which will be commited
       
  • ​git add [file]
  • git add .
    •  Prepare the content staged for the next commit
       
  • git commit -m "Some message "
    • Stores the current contents in a new commit

 Synchronize changes

  •  git fetch [bookmark]
    • Download objects and refs from another repository
       
  • ​git merge [bookmark]/[branch]
    • Join two or more development histories together

 Synchronize changes

  • git push [alias] [branch]
    • Update remote refs along with associated objects
       
  • git pull
    • Fetch from and integrate with another repository

GUI for Git

 GUI for Git

Questions?

[Git] Git Basics

By telerikacademy

[Git] Git Basics

  • 1,547