Git and GitHub – A Quick Look

by admin

Posted on 08/19/17 6:36 AM

Is Git just another word for GitHub, are they related or are they completely different? – This post is specifically built to answers such trivial questions faced by most folks.

So, Let’s get cracking…

What is Git?

First thing first, Git is not Github. They are different yet, related to each other. Git is the most popular version control system founded in 2005 by Linus Torvalds. Git installs locally on your computer to handle ‘version control’. So, to understand git, you should first learn about version control.

Version control, in specific terms, help you record changes to files or set of files so that you can recall previous versions later. It’s just like – making small changes, taking snapshot; making small changes and taking another snapshot; so on…You can then, use Git to step back and forth whenever necessary through each snapshot.

And, Git is simply one of many version control systems that you can download and install in your machine.

Collaboration…If you are working as an individual, then its great. But, what if you want to share your project directory with team – make changes, send them to your team members or have changes they make appear on your machine’s project directory?

For this, Git has a command called Push and Pull, which allows to pull in your collaborators changes and push back your own changes. This is good until you and your collaborators are sitting right next to each other.

Well, that’s where GitHub comes! GitHub is a place for storing identical working directories – also called as repositories or repo. It provides a hub for Git repositories.

GitHub is specifically built for Git, yet, they aren’t really linked. You can use any other Git hosting service apart from GitHub. One such alternative is Bitbucket. (Unlike GitHub) Bitbucket gives private access to repositories.

Now, Let’s discuss three main characterstic functions of Git…

➨ Creating a local repository of project under project_name/.git directory in your home directory.

➨ Creating directory which allows you to directly see the files. Also, called working area.

➨ Creating staging area where you can store changes to file before any commit.


Time to get little deeper into how Git works…

➨ Setup, i.e. download Git for OSX, Windows or Linux.

➨ Create a new repository using command: git init

➨ Create working copy of local repository: git clone /path/to/repository

➨ To recall, our local repository consist of three ‘trees’ maintained by git.

➨ Add and commit changes using following commands:

git add <filename>

git commit -m "Commit message"

➨ To push changes from local to remote repository, use: git push origin master.

➨ Branches are used for developing features that isolates from each other.

To create new branch:

git checkout -b feature_x

To delete a branch:

git branch -d feature_x

To push branch to remote repository:

git push origin <branch>

➨ To update and merge changes,

Update local repository to newest commit and merge remote changes:

git pull

To merge another with your active branch:

git merge <branch>

➨ To study repository history, use:

git log

And, there are lot more things that you can do with git.

Concluding the topic: You must have now got a basic understanding of what Git and GitHub is all about. They are not difficult to grasp, as once you have gotten handle on the basics, you can pick everything up reasonably quickly.

Thanks for reading, folks! See you again with my another interesting post. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *