Disparity and Similarities between Git and Github.

Getting to know more about git and github

ยท

6 min read

Disparity and Similarities between Git and Github.

What is git, what is github, of course all this seem more like what you've been hearing for a very long time but this article will totally change your perspective of things on git and github. As a beginner or as a mid-level developer, you've been coming across a lot of things concerning git and github and you are somehow in a state of confusion and a lot of questions has been dropping on your mind. Questions like:

  • What is Git.
  • What is Github.
  • Is Git a short form of Github.
  • What are the differences between Git and Github
  • How do developers who work remotely communicate and share their code with other team members. and so....

All this questions will be explained in full details, we will move from beginner level to the advance level

So then, grab your cup of coffee as we move into the full details.

What is Git

The word git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, nonlinear workflows.

Does that sound explanatory enough? okay fine let me break it down, come to think of scenario whereby you made changes to a specific portion of your code and then the next day, you have forgotten where you stopped or where you made changes to. But with the help of git you can of course check where you stopped and also be able to track exactly where you made the changes, sounds cool right?

Now the questions that come to your is? How do I perform all this thing, no need to be disturbed man, of course we have commands that we use for all this things and I will explain all the commands one after the other as we move on.

Fair enough right?

What is Github

GitHub, Inc. is a provider of Internet hosting for software development and version control using Git. It offers the distributed version control and source code management functionality of Git, plus its own features.

Here we are, to clear any misconception you may have on Git and Github, I will take my time to explain what the sole difference between git and github is. As seen above, I mentioned something about internet hosting, does that give you a clique and what the difference between git and github is.

Okay, let me explain

Git are stored locally on your system, but come to thing of a scenario whereby you laptop or any other device you are using crashed or got stolen or got lost or .....

What do you think will happen to all the codes you have writing, does that means you have lost everything? definitely NO. You are probably wondering why I said no, this is where github comes in. Github is a remote server that help to house every of the code you have initially converted to git.

Does that sound confusing? No, it shouldn't. The thing here is when you have saved your code with git, you can then proceed to push them to github which give you access to your code anywhere the need for that arises. Even if you travel down to the moon and there is a need for you to make some edit, sound funny right? with you code on github, you can edit the code on any machine and anywhere around the world.

More on Git

  • Git is locally Installed.
  • It was Released in 2005
  • It is Open Source
  • It make use of the Command-line tool
  • It is Focused on version control
  • It has a desktop interface called "Git Gui" -It is maintained by Linux Foundation

More on Github

  • It is cloud based.
  • It was released in 2008
  • Fermium model (Free & Paid)
  • It is web based administrated.
  • It focus on centralised source code
  • It has a desktop interface called "GitHub Disktop"
  • It was acquired by Microsoft in 2008
  • It also encourage developers to contribute in open source projects.

Having establish all these things, let move on to the command used with Git and Github

Note: You must have git installed on your system before you can run all these commands, if you don't, head over to your browser to download the setup and then, we are good to go.

Here are the commands,

A quick one before we proceed

Code stored as git are called repository shortened to be repo

git --version

This command shows the version of Git installed on your machine.

git init

This command will initialize the project folder into a " git repository " Note: Make sure you are in the directory where you want the git folder to be initialized in.

The following commands will only work after you have initialize an empty repository in your current folder.

git status

In simple terms, this command will show you exactly which files / folders have been modified and are yet to be staged.

git add <file>

This is the command you will use to add all your files to the git staging area. It can done in two ways:

git add . This command will add everything you have in the current directory, not leaving out a single file.

git add <specific file>

This is use to add individual files to the staging area. For e.g, git add " index.html "

gitandgithub.png Moving on,

git diff

This command will show the difference between a file in the staging area and file that's present in the working tree ( Untracked file ). i.e. it will show difference between made to a particular file.

git commit -m 'msg'

This command will save your changes to your local repository. The msg is the commit message you want to add to the particular commit. It's good practice to include proper commit message which helps in debugging.

git push

This command will push all the local changes that you've made to the remote github repository

git pull

This command will pull ( fetch ) all the updated code from the remote branch and merge it with your local branch.

git log

This command will list down the entire commit history i.e, all the commits that you've made till now.

Moving on, In git we have what we call branches, just like a tree, all the branches are connected to the major branch. Here are some of the commands we use with git branches

git branch <name>

This command is used to create a new branch in your local git repository

git branch

This command will list down all the local branches that you've created

git branch -a

This command will list down all the branches i.e, local branches + remote branches that's available for checkout

git branch -D <name>

This command will forcefully delete the specified local branch ( even if the changes are not committed )

git checkout<branch_name>

This command used to switch between local git branches

git stash

This command is used to temporarily remove the changes that you've made on the working tree

git remote

This command will give the name of the remote repository For e.g, " origin " or " upstream "

git remote -v

This command will give the name as well as the url of the remote repository

Yo! here is where we will stop for this article, guess you now have more insight on what git and github means and the differences and relationship between the two.

Thanks for reading, don't forget to like and drop your views on this article.

ย