Github Introduction
@ Daniel Smith | Saturday, Oct 24, 2020 | 3 minute read | Update at Saturday, Oct 24, 2020

In this post we will go into using git with Github in order to version control and track your code.

Github and Version Control

Introduction

Version Control is one of the most important concepts when getting started with learning to code. Think of it as the save function in a video game. If we were to not have the ability to save our progress, and something went wrong and we lost our code, we would need to start all over from the beginning and recreate it. With git, we have a means of saving and tracking our progress so that we can keep our code safe. With Github, we have a platform and visual interface that makes this process easier.

Video Guide

Definitions

  • Git:

“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."

reference - https://git-scm.com/

  • Github:

“GitHub, Inc. is an American multinational corporation that provides hosting for software development and version control using Git. It offers the distributed version control and source code management (SCM) functionality of Git, plus its own features."

reference - https://en.wikipedia.org/wiki/GitHub

Examples

Setting up a repository

Initialize repo

mkdir ~/example-repo
cd ~/example-repo
git init

Create Readme File

touch README.md

Check Git Status to See Untracked File

git status

Add File to Staging

git add README.md

Check Git Status to See Staged File

git status

Commit Staged File Changes

git commit -m "example commit message"

Check Git Status to Ensure File was Committed

git status

Add Remote Repository

git remote add origin https://github.com/example-user/example-repository.git

Push Committed File to History

git push -u origin main

Check Git Status to Ensure Local Repo Up to Date with Remote Repo

git status

Modify Readme File

echo 'example repo' > README.md

Check Git Status to See Unstaged Changes

git status

Stage New File Changes

git add README.md

Commit Staged File Changes

git commit -m "updated example file"

Check Git Status to Ensure File was Committed

git status

Push Committed File to History

git push -u origin main

Check Git Status to Ensure Local Repo Up to Date with Remote Repo

git status

Summary

We went into some of the fundamentals of Git and how to set up remote tracking and version control through Github. Using these techniques, you can save your progress as you code and track these changes remotely so your code never gets lost.

Feel free to reach out with any questions and I will do my best to answer and help!

More Git Documentation

Github Git Guide

About Me

Daniel Smith headshot photo

My name is Daniel Smith and this is my blog where I share everything I learn related to blockchain.

I work professionally as a programmer and have a strong passion for automation, efficiency, and teaching others.

Personal Website

I hope you find the information here useful and encourage you all to reach out if you ever have any questions and I will do my best to help.

Let’s Decentralize the World Together!

Social Links