From Sorting Potatoes to the Terminal and Git. PS What's a Terminal?

So I'm not sure what I've gotten myself into.

A couple of weeks ago, I decided to take on the Altcampus Full Stack Web Developer Program.

This is a new online coding bootcamp launched by 4 awesome guys in India.

They already have a very successful offline version of this bootcamp at their campus in the gorgeous Himalayas (they've helped many newbie coders to be job-ready in 6 months) - but now they're taking their expert mentorship online.

So here I am, giving it a go!

Now, to be clear, I know nothing about coding. I am a South African Biomolecular Technologist who never used her fancy honours degree.

Throughout my childhood, I heard countless adults tell me how they wished they had traveled in their 20's - so as soon as I graduated from university, I decided to do everything in my power to do just that.

I became an Amazon Rainforest guide in Ecuador and Peru, then a potato factory worker in Scotland, then an English instructor in South Korea, then a remote recruiting manager for an ESL company in England - and now I'm a full-time digital nomad who has founded a global co-working platform for women who work online (called Online CoWork ).

I can tell you a bit about how to grow lung cancer cells in a lab - or how to stand on 7 continents before you're 35!

I can even tell you how to sort deadly green potatoes from the good ones (did you know that the green spots on potatoes are deadly?!).

But as for coding...

Day 1: 'Ok, so open your terminal' - huh? What's a terminal?

Day 3: 'Ok sign in to Github and make a new branch' - Umm, Git branch... what?

#givemestrength

I am not sure what I've gotten myself into... but I'm writing this blog to share with you what I'm learning. I'm hoping to look back on this with a big grin on my face sometime next year! :)

I'm excited.

So here's what I've learned in the past few of days:

Basic Unix Commands

So Unix is a family of operating systems such as MacOs, Android, etc - but apparently doesn't include Windows (Now I know why I switched to Mac ;) )

It's basically an interface between the user and the computer (aka the hardware).

Now the core of Unix is called the kernel. The kernel controls and manages everything in the system.

Then, there's the shell, which allows the user to communicate with the kernel. On a Windows machine, you need to download 'Gitbash' to access the Linux shell.

Now, this is where the terminal comes in! The terminal contains a CLI - a command line interface - where we can input commands to control the kernel.

The terminal has a 'prompt' which can be a dollar sign ($) or a percentage sign (%). This is where we type our commands.

Here are some common commands:

  • echo prints the output
  • ls lists everything in that particular directory
  • cd <directoryname> changes directory
  • cd .. takes us one level back to previous directory
  • man lets us see the manual
  • clear clears the screen of terminal
  • exit exits the terminal
  • touch <filename> creates a new file
  • head <filename> prints the first 10 lines from the top of the file
  • tail <filename> prints the last 10 lines from the bottom of the file
  • nano <filename> opens the editor for you to edit the file
  • grep <directory> <filename> searches for text in a file
  • rm <filename> deletes files
  • mkdir <directoryname> creates a new directory
  • rmdir <directoryname> deletes a directory
  • cp <source> <destination> copies files or folders

*PS Be careful of escape characters!

CRUD

In computer programming, the above can be referred to as CRUD operations. They instruct the system to:

  • Create
  • Read
  • Update
  • Delete

CRUD operations can be used at both the file and folder level.

GIT

Git is a version control system. It's kind of like when you're writing a blog article - or editing a video.

You end up with file names like:

  • janebookfinal.doc
  • janebookfinalfinal.doc
  • janebookfinalfinalrealfinal.doc
  • janebookfinalfinalrealfinalLAST.doc

(I see you smiling right now)

Well, git makes things a little easier. It takes snapshots of your code edits which are called commits and creates a commit graph which allows us to easily be in control of our code edit history.

The 3 Stages of Git

Now, there are three stages involved here.

1) The Untracked Area (the working tree) - this is what we see on our systems

2) The Staging Area - this is when Git starts tracking the changes

3) The Committed Stage - a final snapshot is taken of that version of code

We need to move our code through these 3 stages in order to create a roadmap of our code history.

To do this, we need to type various commands into our terminal.

  • git init intializes a folder with git

  • git status gives us the current status of the current repository we're working on

  • git add <filename> moves the file from the untracked area to the staging area. When you have to add all the files and folders, use git add .

  • git commit -m "Fixed header bug" creates the commit and assigns a unique ID to it. We can also give this commit a message about what we did to the code here - such as 'Fixed header bug'.

  • git log shows the commit history

Branching and Merging

This is where things can easily become overwhelming! But no need to panic.

(I'm focusing on this as more of a 'learn while doing' rather than trying to understand it 100% at the start!)

As we all know, many people often work on one coding project. But this can become a little dangerous (and pretty much impossible!) if everyone is working on the same code at the same time.

Enter branching and merging.

Basically, if you have a project that you're working on, you might have an expert friend who can help you fix a bug that you're stuck on.

In order to do this, we don't just hand all of our code to our friend. We have he/she make a copy (branch) of the particular code that needs working on.

He/she then works on it, sends it back to us, we review it and then merge it with our original code.

It sounds pretty straight forward, right?

Well, it seems it can get complex with multiple users.

You can have fast-forward merges or 3-way merges... and then there's hot fixes!

And of course, with all of the above, there has to be some merge conflicts to deal with.

SIDENOTE: How do we resolve a merge conflict? It can be as simple as opening your code editor, viewing the highlighted conflict and editing it to your preference.

Here are some of the common commands we use for merging and branching:

  • git branch <branchname> creates a new branch

  • git checkout <branchname> switches to a specific branch

  • git merge <branchname> merges the given branch to the current branch

  • git branch -d <branchname> deletes the given branch

  • git checkout -b <branchname> creates and switches to the new branch

NOTE: We will see the word "HEAD" next to the current commit that we're working on

GitHub

In this next section, we'll talk about an awesome platform called Github which allows teams to collaborate no matter which part of the world they're in!

Everyone can do their bit to fix bugs and/or add features without upsetting the main project.

A bit more about GitHub:

  • It's a distributed version control system.

  • It allows developers to see which changes were made, when they were made, what the changes were and why the changes were needed.

  • It lets developers see the entire timeline of the project in one place.

  • It also allows experts to easily be assigned to different parts of the project to collaborate for the best result.

First Day on Github

Github has an awesome 'onboarding training' called First Day on Github.

Here are some of the things I learned:

1) Github flow - how to open an issue and assign it, close the issue

Create a branch > add commits > open a pull request > discuss and review code > merge > deploy

3) Models for how to collaborate with others

  • a) Shared Method
  • b) Fork and Pull Method

4) Git Project - the entire collection of files and folders associated with the project

5) Repositories - places where git projects are stored. They allow interaction with the code history, cloning, committing, merging, comparing versions, creating branches, etc.

6) How to use Markdown Syntax - a way to communicate on Github to make text bold, italics, add an image, make an ordered list, add emojis, etc. Markdown can be used in many places on Github - comments, files with .md or .markdown extensions, etc.

For example, if we want to make the text bold we can wrap it with double asterisks **.

7) Moving projects to Github - we need to remove binary files such as spreadsheets or slides. You can add a .gitignore file for this. There are many templates for .gitignore on Github.

8) I even created my first GitHub page.

Conclusion

Wow! After just a few days I have to say that I am amazed at how things are starting to become more familiar.

"Terminal" is no longer a word that means 'the end'. It is only the beginning :)

AltCampus, thanks for this awesome opportunity... I'm excited!

Did you find this article valuable?

Support Hayley is Coding ๐Ÿฆ‹ by becoming a sponsor. Any amount is appreciated!