Git Fundamentals

About Me

DevOps@RajeshKumar.XYZ

Introduction to Git

Overview

  • Brief history of version control
  • Overview of Git
  • Installing Git
  • Configuring Git

A Brief History of Version Control

  • First Generation
    • Single-file
    • Animation
    • No networking
    • e.g. SCCS, RCS
  • Second Generation
    • Multi-file
    • Centralized
    • e.g. CVS, VSS, SVN, TFS, Perforce

Advantages of DVCS

  • Different topologies
    • Centralized
      • Developers push changes to one central repository
  • Hierarchical
      • Developers push changes to subsystem-based repositories
      • Sub-system repositories are periodically merged into a main repository
  • Distributed
      • Developers push changes to their own repository
      • Project maintainers pull changes into the official repository
  • Backups are easy
    • Each clone is a full backup
  • Reliable branching/merging
    • Feature branches
    • Always work under version control
    • Applying fixes to different branches
  • Full local history
    • Compute repository statistics
    • Analyze regressions
  • New ideas
    • Deployment
      • git push heroku prod_branch

About Git

  • Created by Linus Torvalds, who also created Linux
  • Prompted by Linux-BitKeeper separation
  • Started in 2005
  • Written in Perl and C
  • Runs on Linux, OS X, Windows, and many other operating systems
  • Design goals
    • Speed
    • Simplicity
    • Strong branch/merge support
    • Distributed
    • Scales well for large projects

Installing Git

Configuring Git

  • System-level configuration
    • git config --system
    • Stored in /etc/gitconfig or c:\Program Files (x86)\Git\etc\gitconfig
  • User-level configuration
    • git config --global
    • Stored in ~/.gitconfig or c:\Users\\.gitconfig
  • Repository-level configuration
    • git config
    • Stored in .git/config in each repo

Summary

  • Brief history of version control
  • Advantages of DVCS
  • Overview of Git
  • Installing Git
  • Configuring Git

Working Locally with Git

Overview

  • Creating a local repository
  • Adding files
  • Commiting changes
  • Viewing history
  • Viewing a diff
  • Working copy, staging, and repository
  • Deleting files
  • Cleaning the working copy
  • Ignoring files with .gitignore

Summary

  • Creating a local repository
  • Adding, updating, and deleting files
  • Commiting changes
  • Viewing history and diffs
  • Working copy, staging, and repository
  • Cleaning the working copy
  • Ignoring files with .gitignore

Working Remotely with Git

Overview

  • Cloning a remote repository
  • Listing remote repositories
  • Fetching changes from a remote
  • Merging changes
  • Pulling from a remote
  • Pushing changes remotely
  • Working with tags

Git Protocols

Protocol Port Example Notes
http(s) 80/443 https://github.com/
jquery/jquery.git
Read-write Password for auth Firewall friendly
git 9418 git://github.com/
jquery/jquery.git
Read-only Anonymous only
ssh 22 git@github.com:jquery
/jquery.git
Read-write SSH keys for auth
file n/a /Users/James/code/jquery Read-write Local only

Summary

  • Cloning a remote repository
  • Fetching and pulling from a remote repository
  • Pushing changes
  • Working with tags

Branching, Merging, and Rebasing with Git

Overview

  • Working with local branches
  • Stashing changes
  • Merging branches
  • Rebasing commits
  • Cherry-picking commits
  • Working with remote branches

Summary

  • Local and remote branches
  • Stashing changes
  • Merging, rebasing, and cherry-picking

Questions

Thank You