Skip to content

Chapter 6: GIT Version Control System

Saranga Wijeratne edited this page Aug 22, 2018 · 20 revisions

What is Version Control

System that records changes to a file or set of files over time so that you can recall specific version later

https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control

  • Version control important when collaborating with others

What is GIT in a nutshell?

  • Stream of snapshots

https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

  • Created by the same people who developed Linux
  • Can operate through the terminal

GIT installation

  • Download the GIT from the following link for your operating system.

https://git-scm.com/downloads

  • Follow the on-screen instruction to get the GIT onto your system

Configure your GIT environment

git config --global user.name "Your git username"
git config --global user.email "your email"
  • Only need to do this once
  • Check the configuration

$ git config --list

Introduction to GitHub

GitHub is a web-based hosting service for version control using git

  • Set up a GitHub account
  • Navigating GitHub
  • GitHub profile personalizing

Git and GitHub

  • Git Local and on your computer
  • GitHub Remote

Important: You don't need GitHub to use Git but GitHub allows you to share and collaborate with other users. Also, gives your local repository a backup.

Creating a New Repository

  1. Start a repository from scratch
  2. "Fork" another user's repository/repo

Step 1

Step 2

  • Provide a name for your repo
  • A brief description to your repo
  • Select the box next to "Initialize this repository with a README"
  • Add a license if needed
  • Hit the "Create repository"

Creating a Local Copy of Git Repo

Step 1

Make a directory for your new repo

mkdir test-hcs

# Navigate into the folder you just created

cd test-hcs

Step 2

Initialize a local Git repo

git init

Step 3

Point out your local directory to remote directory.

git remote add origin https://github.com/HCS7194-AU18/test-hcs.git

Step 4

Get content of the remote repo to working_dir

git pull origin master

Add/Edit your content

Step 1

Edit your README.md file

Step 2

Add the changes to the local repo

# Add all new files
git add .

Step 3

git commit -m "My first edit"

Note: This only updates the local repo but not the remote repo

Pushing the repo to the remote repo

git push origin master

Other ways to get a repo

  • fork a repo
  • clone a repo