Github Branching
@ Daniel Smith | Sunday, Oct 25, 2020 | 2 minute read | Update at Sunday, Oct 25, 2020

In this post we will go into using git branching with Github in order to keep changes isolated from each other until ready to release.

Git Branching with Github

Introduction

With git, we have a means of saving and tracking our progress so that we can keep our code safe. With git branching, we have a means to keep changes separated and isolated while they’re being worked on. This makes it much nicer and easier to work on a codebase in a team as issues can be tracked and worked on with separate branches which get worked on by different people. By following this git workflow, it’s possible for many developers to work in parallel without worry about breaking code.

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/

  • Branching:

“Branching means you diverge from the main line of development and continue to do work without messing with that main line."

reference - https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell

Examples

Creating a New Branch

Check Git Status to Ensure Curent Branch Up to Date

git status

Check Git Branch to See Available Branches

git branch

Switch to Main Branch if Needed

git checkout main

Checkout New Branch from Current Branch

git checkout -b example-branch

Check Git Branch to See Available Branches

git branch

Push New Branch to Remote Repository to Track It

git push --set-upstream origin example-branch

Create New File and Check Git Status

touch example.txt
git status

Stage New File and Commit to Git

git add example.txt
git commit -m "add example.txt file"

Push Commit to Remote Git Repository

git push -u origin example-branch

Check Differences between branches with Git Diff

git diff example-branch main

Summary

We went into some of the fundamentals of Git and how to set up isolation through branching. Using these techniques, you can work on several features at the same time in a team without worry about breaking the main code.

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

More Git Documentation

Git Branching 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