Basic Git and Linux Commands Part 1

TechKalam
2 min readJan 15, 2021
Photo by Yancy Min on Unsplash

Welcome

Here we will look into git commands that are used frequently. But before that what is git ?

Introduction

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.

This is the definition given at their official website. For simplicity, I’ll drop all and say,

Git is a version control system

When we are working on something we may sometimes feel like, “It’s better if I back up somewhere before I do any more changes”, we may do this multiple times.This is versioning. We basically make multiple versions of a project so that we can revisit when needed. Git helps us with versioning.

Installation

sudo apt install git

That’s it. now you have git installed. Before starting anything I recommend you to set your email and name.

git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"

You can rerun these commands if you want to change your name or email.

Okay now you are ready to learn some basics

Basic Linux commands

Linux uses cd to change from on directory to another. Directory is folder in other term. ~ is home directory. mkdir is to make a directory. With this basic linux commands, we will create a folder named “welcome” in home directory.

cd ~
mkdir welcome

Now we will create two files “hello.txt”, “world.txt” inside “welcome” folder. To create a file we use touch command.

cd welcome
touch hello.txt
touch world.txt

I can go on with linux commands but I prefer not to. All what we did up to now is create a folder and files. We have not started with git yet. Before we start working with git, we have to initiate a given folder with git.

Basic Git commands

To initiate git inside welcome folder, run following command.

git init .

That’s it, now we have successfully initialized an empty git repository. The dot (.) means current directory in linux, .. means previous directory.

Now it’s time to make first version of our folder. To do that run following commands.

git add .
git commit -m "my first commit"

Great, you have successfully made a version back up of your project, in some other words commit.

--

--

TechKalam

Techkalam is a professional software, website development company based in Srilanka