Skip to content

Latest commit

 

History

History
221 lines (130 loc) · 4.21 KB

README.md

File metadata and controls

221 lines (130 loc) · 4.21 KB

Git Workshop


Agenda

  1. Why use Git
  2. What is Git
  3. How does Git Work
  4. Recap
  5. Installing Git
  6. Git Activity

Why use Git

Imagine yourself as a software developer in company. You're working in a team of 5 people. Everyone needs to make changes to files

To collaborate, we need a way of:

  • Tracking the version of the files
  • Distribute the files to each member
  • Using changes from other people

What is Git

Git

Git is a version control system. There are many version control systems, but git is a very popular one. Git provides a set of commands that allow you to interact with it.

Version Control System

It's a system that allows you to record edits to files over time. Hence the name. Version control systems allow groups of people to edit the same files and have a clean way of controlling the version and order of changes.


How Git Works

git_diagram


How Git Works cont

  • Download the project from your online codebase

    Git terms: Clone the repository

  • You now have your own copy of the project

    Git terms: You now have a working directory

  • After editing your file

    Git terms: You have unstaged changes

  • Tell git which files you changed

    Git terms: Stage your changes to your local repository

  • Upload your changes to your online codebase

    Git terms: Push your changes to your remote repository

  • When someone else uploads changes you can grab them

    Git terms: Pull the changes


Recap

recap


Installing Git

  • macOS

    # install brew
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    # install git
    brew install git
  • Linux (Debian based)

apt-get install git

Installing Git


Installing Git

  • Open the terminal (macOS, Linux) or git bash application (Windows)
# Check if git is installed
git
  • Should see a list of possible commands

Creating an account on Github

alt text


Git Activity

Adding your own contributions to our workshop webpage


Git Activity

View Repository

alt text


Git Activity

Clone Repository

  • Open your terminal or (or Git Bash if you're on Windows) and navigate to a folder you want to clone to

    cd path/to/directory

  • Clone the repository

    git clone https://github.com/CarletonSLAM/git-workshop

  • Navigate to you the repoository

    cd git-workshop

  • Create your own branch

    git branch YOUR_BRANCH_NAME

  • Checkout to your branch

    git checkout YOUR_BRANCH_NAME


Git Activity

Modify file

  • Navigate to the docs folder and open index.html in a text editor.

  • Add your own name and program in a h3 tag in the middle of the body tag i.e.

<h3>Jacky - Software Engineering </h3>
  • Save the file.

Git Activity

Add and Commit

We now want to stage our changes and commit them.

git add index.html
git commit -m "Description of your changes"

Git Activity

Push

# Check the status
git status

# Push to your branch if everything looks good
git push origin YOUR_BRANCH_NAME

Git Activity

Pull Request

Go to the repository website and you'll be prompted to make a pull request


Recap

recap