Git Overview

What is Git?

  • Version control for Programmers

  • Like Microsoft Word “Track Changes” feature with superpowers

  • Makes it easy for programmers to collaborate and work on the same codebase

  • SVN (subversion) and CVS are other version control programs (Git is the most popular)


What is Github?

  • Web-based Git repository hosting service

  • Built on top of git

  • Home to +90% of all open source projects

  • Morphed into a “social network” for developers


Vocabulary

  • Repository
  • Commit
  • Branch
  • Merge
  • Push
  • Pull
  • Fork
  • Clone
  • Pull Request

Respository

  • Most basic element of GitHub

  • A repository can be referred to as a projeect

  • contains all of a project’s files

  • Stores each file’s revision history

  • Repositories can have multiple collaborators and can be either public or private.


Commit

  • A “revision”, is an individual change to a file (or set of files)

  • Git’s version of “saving”

  • Commits save a “snapshot” of all of the project’s files at that point in time

  • Using commits you can “time travel” and navigate back to any previous commit that was made throughout the history of the project

  • Commits usually contain a commit message which is a brief description of what changes were made


Branch

  • Parallel version of a repository

  • Branches allow developers to work on new features without affecting the “master” branch and disrupting the “live” version

  • The process of creating a separate branch to work on a feature is referred to as “creating a feature branch

  • After developers have added their new feature (on their feature branch) they will then make a Pull Request (which is a request for comments and a request to Merge their changes back into the main branch (master branch))


Master Branch

  • The default branch found in every Git respository

  • For most companies, the master branch reflects that latest version of production code (i.e. working code available to customers)


Merge

  • Merging takes the changes from one branch (in the same repository or from a fork), and applies them into another

  • This often happens as a Pull Request (which can be thought of as a request for comments and a request to merge into the another branch - usually the master branch)


Push

  • Refers to sending your committed changes to a remote repository such as GitHub.com

  • For instance, if you change something locally, you’d want to then push those changes so that others may access them


Pull

  • Pulls code from a remote repository and merges it with code in your local repository (on your computer)

Fork

  • A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project

  • Most commonly, forks are used to either propose changes to someone else’s project or to use someone else’s project as a starting point for your own idea


Clone

  • Copies a remote repository (i.e. repository in the cloud on a platform like Github.com) and creates a local copy of the repository on your computer

  • Cloning creates a link between the the remote and local copy of a repository, allowing you to your code in sync between the two


Pull Request

  • Pull requests are proposed changes to a repository submitted by a user and accepted or rejected by a repository’s collaborators (i.e. team members).

  • Pull requests can be thought of as a developer asking for permission to merge their changes into the master branch

  • Pull requests each have their own discussion forum, where developer can discuss the changes requested and suggest further revisions.

  • This discussion as also referred to as Code Reviews

Great resource for all things git can be found here