Introduction

What is git?

  • Git is a version control system
  • It takes snapshots of the files in a folder
  • It was designed to track changes to plain text files
  • It also stores metadata about the changes, such as who made them, when they were, and, if used correctly, why they were made

What is GitHub?

  • GitHub is a cloud-based hosting service for git
  • There are many other hosting services, such as GitLab and BitBucket
  • You can think of these services and being to git what GMail, Outlook and Hotmail are to e-mails
  • GitHub became the most popular git hosting service because of its collaboration features

Git repositories

Repository

  • Git takes snapshots of the files in a folder
  • We call the folder a repository or repo
  • There is a copy of this folder in the cloud, which we call the origin
  • And we can create local copies in our computers by cloning repositories

Cloning a repository

  1. Open the repository on your web browser
  2. Click on the green Code button
  3. Select Open with GitHub desktop
  4. If prompted, click on Open GitHub desktop

This should launch GitHub Desktop

Working on a local repo

  1. On the top left corner, click onn Current repository - git-training
  2. On the dropdown menu, right click on git-training
  3. Click on Show in Explorer or Show in Finder

What do you see in this folder? How does it compare to the content you see in the browser?

Fetching and pulling

Fetching and pulling

  • When we work with file sharing software, they are constantly syncing files between the cloud and our computers
  • In git, however, every action is intentional, including checking if there are changes in the cloud and syncing them to your computer

What does that mean? Let's do a test.

Fetching and pulling

  1. Open the repository in your browser and make an edit to the README.md file
  2. When prompted, commit your changes

Do you see your changes in the browser now? Do you see them in your local copy of this file?

Fetching and pulling

  1. On GitHub Desktop, click on the button that says Fetch origin
  2. Click on Pull origin
  3. Open the local copy of README.md again

Do you see the changes now?

Fetching and pulling

  • "Fetching" means syncing with the cloud and checking if there are any updates in the repository
  • "Pulling" means bringing any changes present in the origin into your local copy

Commits

Making commits locally

  1. Create a new file inside your local copy of the repository
  2. Go to GitHub desktop

Can you see what changes you made?

Making commits locally

  1. Write a commit message to describe your changes under Summary (required)
  2. Click on Commit to main
  3. Go to the History tab. Can you see your commit there?
  4. Now go to the browser. Can you see your changes there?

Pushing changes

Pushing changes

  • Remember that every action in git is intentional
  • To send changes from your computer to the cloud, you need to push them
  • "Pushing" means sending your changes to the cloud

  1. On GitHub Desktop, click on Push origin

Can you see your changes in the browser now?

Branches

Let's practice

Command line git

Merging branches

Recap

Thank you!