Skip to main content

Featured

SQL vs NoSQL.

SQL vs NoSQL.   By  Jeewantha Hiddalarachchi. In this tutorial, I going to discuss the difference between SQL and NoSQL databases. Let's start with a brief explanation about SQL and NoSQL. What is SQL? Structured Query language (SQL) is the standard language to communicate and deal with relational databases.  A relational database is a form of tables. Basically, we use SQL to insert, search, update and delete database records but it helps users to do lots of things like optimizing and maintenance of databases. SQL databases are table-based databases and there are vertically scalable. Not only that but also SQL has a predefined schema and always requires specialized DB hardware for better performance. Examples SQL databases -   MySQL  Microsoft SQL Server Oracle Sybase What is NoSQL? NoSQL is a non-relational Database Management System. And also NoSQL not like SQL because it does not require a fixed schema, avoids joins. It is mainly focused on scaling, fast queries, allowing for fr

Introduction to Git and GitHub (Part 01).

Introduction to Git and GitHub (Part 01).

By Jeewantha Hiddalarachchi.


Are you new to git? Don't worry. You can get a better idea about git and GitHub and their basic functionalities through this article. Let's get a basic idea about Git, Github, and using git command lines.

What is git?

git is software tracking changes in any kind of file. It used to collaborate developing source codes during software development. Therefore It helps coordinate work among developers. 

In 2005, Finnish-American software engineer Linus Benedict Torvalds created git for the development of the Linux kernel. 

Not only sharing source codes but also git helps to speed of sharing source codes, data integrity, and support for distributed non-linear workflows. 

Are git and GitHub the same? If Not, what is the GitHub?

Exactly No. As mentioned above, git is an open-source software tracking and version control tool but GitHub makes tools that are integrated with git. As simply, git can work without GitHub, but GitHub does not. The functionality of GitHub definitely requires git. 

GitHub is a company that provides Internet hosting for software development and also distributed version control tools with git functionality and its own features. Not only those but also GitHub gives facilities to access control, bug tracking, task management.

Also, you can try the following products instead of GitHub;

Let's get some knowledge about how to work with git and GitHub using commands.

Step 1 - Installing git and create a Github account.

    Step 1.1 - Installing git to your computer.

        Please follow those instructions here to install git to your PC.

    Step 1.2 - Create a free Github account.

        To create a free account, click here.

Step 2 - Create a local git repository (repo) and Initialization.

    Step 2.1 - Create a local git repository

First your want to create a folder as your local repository. To create a new folder using the git bash terminal, we use mkdir (make directory). Then open a git bash terminal and go to the local repository by using the cd (change directory) command.

Or you also can go to the newly created local repository folder and open the git bash terminal inside it.

$ mkdir myProject
$ cd myProject

    Step 2.2 - Initialize git repository.

We use the git init command to initialize the git repository.

$ git init

Step 3- Set up name and email in git-config.

    Step 3.1 - Set up name and email for every repository.

The below commands help to specify user and user email for git account and you can see those saved details in the manage credentials in your windows PC (Control Panel >     User Accounts > Credential Manager).

$ git config --global user.name "Your Name Here"
$ git config --global user.email "your_email@example.com"

For confirming git username and email correctly:

for user name - $ git config --global user.name
for email - $ git config --global user.email

    Step 3.2 - Set up name and email for a single repository.

$ git config user.name "Your Name Here"
$ git config user.email "your_email@example.com"

For confirming git username and email correctly:

for user name$ git config user.name
for email$ git config user.email

For checking git config, use git config --list command.

git config --list

Step 4 - Add a new file to the local git repository.

Use that touch command to create and save it automatically as a blank file with your given filename. 

$ touch Your_file_name_here.txt


If you want to identify which files git knows, you can use 
git status command.

git status

Step 5 - Add a file to the staging environment.

First, we want to know about the states of Git. There are three states:
  • Committed - The data stored in the local repository safely.
  • Modified - The user has changed the file but it still not committed to the database yet.
  • Staged - Have marked a modified file in its current version to go into the next commit.
The manipulation among those states occurs locally and therefore all changes are affected by other one's repositories, not users.
States of git

In that git workflow environment, a git file stays in one of three areas at a moment. Those areas are:
  • Working Directory - Current version of the project where users make changes.
  • Staging Area - Area where stage files when preparing those files to commit.
  • Local repository - When commit, git saves permanently only the changes from the stage area to the local repository memeory.
git workflow environment

Using the git add command, we can add a file to the staging area.

$ git add Your_file_name_here.txt

If you want unstage or untrack your added file, use the below command.
 
$ git rm --cached <Your_file_name_here.txt>

Step 6 - Create a commit.

Simply, Commits is a record of changes you have done since your last saved commit. every Commit always associates with a message which describes the reason for the change. Not only that commits always help to initialize the status of the staging environment.

You can commit with a message using:

$ git commit -m 'Your_commit_message' 


All commits to in a record store permanently. If you want to see it, use the git log command. Most recent commit shows as HEAD.

git log


Normally commits contain detail of a new feature or a bug fixing or a Typo fixing. Therefore as a best practice give a meaningful short description for the commit message when you commit. It will be very helpful for future programmers to develop your code in the future.

Summary.

We discussed git and GitHub and some of the useful commands for working with git. And also know about how to git workflow and some tips on how to succeed in your coding with git.  Okay, In my next article I hope to give an idea about branching, pushing codes, pull and merge. You can reach to my next article here.

Also, you can get all the above git commands from my GitHub gist.

Thank you very much for reading and I hope you have a better idea about this topic...😊.

Comments

Popular Posts