Introduction to

Who is this guy?

 

Dale Alleshouse

@HumpbackFreak

hideoushumpbackfreak.com

github.com/dalealleshouse

Git on with it!

What the big deal with Git?

  • Open source project incepted by Linus Torvalds
  • Most widely used source control system
  • GitHub (https://github.com/)

How is Git Different?

  • Subversion is a Centralized Version Control System
  • Git is a Distributed Version Control System (DVCS)
    • Every working copy is also a repository with full change history
  • Snapshots based on Hash generated from a SHA1 algorithm on file contents
    • Guaranteed unique
    • Snapshots can be moved and copied without loss of identity
  • History is distributed graph
    • Automatically determines ideal merge base
    • fix conflicts only once

Advantages

  • Performance
  • Work Disconnected
  • Nonlinear Workflows
    • Pull Requests
    • Multiple Synced Repositories
  • Simplified Merging
  • Ubiquity

Disadvantages

  • Complexity
  • No Exclusive Checkouts

Git

Installing Git

> choco install git -y
> choco install poshgit -y
> choco install tortoisegit -y
> choco install github -y
  • Options
    • Windows Installer (https://git-for-windows.github.io/)
    • Chocolaty (https://chocolatey.org/install)
  • Additional Tools Recommendations
    • Posh-git
    • Tortoise Git
    • GitHub Desktop

Configuring Git

> git config --global user.name "Dale Alleshouse"
> git config --global user.email "dalleshouse@cngholdings.com"
  • Optional Configurations
    • Install SSH key on GitHub (https://help.github.com/articles/generating-an-ssh-key/)
    • Windows Credential Manager (https://github.com/Microsoft/Git-Credential-Manager-for-Windows)
      • choco install git-credential-manager-for-windows -y

Git Basics

Demo

> git clone <GIT URL>

> git add <FILE>

> git add --all

> git commit -m "this is a commit message"

> git status

> git pull

> git push

Branching

Demo

> git branch <BRANCH_NAME>

> git checkout <BRANCH_NAME>

> git diff

> git add --all

> git commit -m "<COMMIT_MESSAGE>"

> git push --set-upstream origin <BRANCH_NAME>

> git push origin :<BRANCH_NAME>

> git checkout master

> git branch -D <BRANCH_NAME>

Merging

Demo

> git checkout <TARGET_BRANCH>

> git merge <SOURCE_BRANCH>

Best Practices

  • Commit Often
  • Perfect Later
  • Publish Once

Now you Git it!

Further Reading

  • https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
  • http://blog.teamtreehouse.com/why-you-should-switch-from-subversion-to-git
  • https://www.atlassian.com/git/tutorials/what-is-version-control/

Introduction to Git

By Dale Alleshouse