Skip to main content

GIT Training Guide

GitHub

GitHub, Inc. is a platform and cloud-based service for software development and version control, allowing developers to store and manage their code.  It is particularly beneficial for distributed development teams.  The complete developer platform to build, scale, and deliver secure software.  Home to 100+ million Developers, 4+ million Organizations, and 420+ million Repositories.  

GitHub offers AICPA System and Organization Controls (SOC) 1 Type 2 and SOC 2 Type 2 reports with IAASB International Standards on Assurance Engagements, ISAE 2000, and ISAE 3402 for GitHub Enterprise Cloud.  GitHub has completed the self-assessment of the Consensus Assessment Initiative Questionnaire (CAIQ) required for Level 1 of the CSA STAR Registry. GitHub has also completed the third-party independent assessment required for Level 2 STAR Certification for ISO/IEC 27001:2013 in the CSA STAR Registry.

Kick off workflows with GitHub events like push, issue creation, or a new release. Combine and configure actions for the services you use, built and maintained by the community.  

Linux, macOS, Windows, ARM, and containers

Hosted runners for every major OS make it easy to build and test all your projects. Run directly on a VM or inside a container. Use your own VMs, in the cloud or on-prem, with self-hosted runners.

Easy publishing

Use industry and community-standard package managers with native tooling commands. Then authenticate and publish directly to GitHub.

                      

Private repositories

  • Plan
    Storage
    Data transfer out
    within Actions
    Data transfer out
    outside of Actions
     
  • Free

    500MB

    Unlimited

    1GB

    per month

     
  • Detect security issues in your pull requests and prevent new vulnerabilities from entering main with automatic scans that leverage machine learning to continuously amp up accuracy.  GitHub supply chain security is designed for developers, built for speed, and free for everyone. All powered by a database of over 12,000 expert-reviewed advisories.  
  • Use Visual Studio Code, Jupyter, or JetBrains with the editor, terminal, debugger, version control, settings sync, and all of your extensions. Work from any device in a browser, or hand off to your desktop.  GitHub’s own 35GB dev image starts in seconds.  Use Codespaces for free each month.  Decide how many cores you need and go. Your free hours reset each month. 

Git basics
Git is a free and open-source version control system, originally created by Linus Torvalds in 2005. Unlike older centralized version control systems such as SVN and CVS, Git is distributed: every developer has the full history of their code repository locally. This makes the initial clone of the repository slower, but subsequent operations such as commit, blame, diff, merge, and log dramatically faster.

Git also has excellent support for branching, merging, and rewriting repository history, which has led to many innovative and powerful workflows and tools. Pull requests are one such popular tool that allows teams to collaborate on Git branches and efficiently review each other's code. Git is the most widely used version control system in the world today and is considered the modern standard for software development.

How Git works

Here is a basic overview of how Git works:

  1. Create a "repository" (project) with a git hosting tool (like Bitbucket)
  2. Copy (or clone) the repository to your local machine
  3. Add a file to your local repo and "commit" (save) the changes
  4. "Push" your changes to your main branch
  5. Make a change to your file with a git hosting tool and commit
  6. "Pull" the changes to your local machine
  7. Create a "branch" (version), make a change, commit the change
  8. Open a "pull request" (propose changes to the main branch)
  9. "Merge" your branch to the main branch

Git download

Mac OS/X

1. Download the latest Git for Mac installer.

2. Follow the prompts to install Git.

3. Verify the installation was successful by typing git --version:

$ git --version
git version 2.9.2

4. Configure your Git username and email using the following commands, replacing Emma's name with your own. These details will be associated with any commits that you create

$ git config --global user.name "Emma Paris"
$ git config --global user.email "eparis@atlassian.com"

Windows

1. Download the latest Git for Windows installer.

2. When you've successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation. The default options are pretty sensible for most users.

3. Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt).

4. Run the following commands to configure your Git username and email using the following commands, replacing Emma's name with your own. These details will be associated with any commits that you create:

$ git config --global user.name "Emma Paris"
$ git config --global user.email "eparis@atlassian.com"

Linux

1. From your Ubuntu shell, install Git using apt-get:

$ sudo apt-get update
$ sudo apt-get install git
$ git --version
git version 2.9.2

From your RedHat shell, install Git using dnf (or yum, on older versions of Fedora):

$ sudo dnf install git

or

$ sudo yum install git

2. Verify the installation was successful by typing git --version:

$ git --version
git version 2.9.2

3. Configure your Git username and email using the following commands, replacing Emma's name with your own. These details will be associated with any commits that you create.

$ git config --global user.name "Emma Paris"
$ git config --global user.email "eparis@atlassian.com"

An SSH key is an access credential for the SSH (secure shell) network protocol. This authenticated and encrypted secure network protocol is used for remote communication between machines on an unsecured open network. SSH is used for remote file transfer, network management, and remote operating system access. The SSH acronym is also used to describe a set of tools used to interact with the SSH protocol.

SSH uses a pair of keys to initiate a secure handshake between remote parties. The key pair contains a public and private key. The private vs public nomenclature can be confusing as they are both called keys. It is more helpful to think of the public key as a "lock" and the private key as the "key". You give the public 'lock' to remote parties to encrypt or 'lock' data. This data is then opened with the 'private' key which you hold in a secure place.

SSH keys are generated through a public key cryptographic algorithm, the most common being RSA or DSA. At a very high level SSH keys are generated through a mathematical formula that takes 2 prime numbers and a random seed variable to output the public and private key. SSH keys are used to authenticate secure connections. Following this guide, you will be able to create and start using an SSH key. Git is capable of using SSH keys instead of traditional password authentication when pushing or pulling to remote repositories.

Generate an SSH Key on Mac, Linux and Git bash.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
> Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
ssh-add -K /Users/you/.ssh/id_rsa

This Git cheat sheet saves you time when you just can't remember what a command is or don't want to use git help in the command line. It is hard to memorize all the important Git commands by heart, so print this out or save it to your desktop to resort to when you get stuck.