Introduction to Git Basic Commands

Introduction to Git Basic Commands

June 15, 2016 devjdg 0 Tags: ,

Overview of Git

Ever heard or read this term in a crowd or in an article? Curious how to get started with its commands? Then this is the article for you.


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. (src:


Aforementioned, Git is a version control system just like Subversion, OpenCVS and other proprietary vcs like AccuRev and Vault.


So what is a version control system? Version Control System is a system that records changes to a file or set of files over time so that you can recall specific versions later. (src:

In a development perspective, vcs is very helpful specially for large enterprise projects. This is also helpful for solo and small projects as for the benefit I have experienced when I started using it last few months.


Mostly used vcs online repositories are Github and Bitbucket. While these two offers almost the same for all of the features they have when combined together, they differ in terms of privacy.


Github stores your repository publicly (Unlimited) only but offers a privacy package which varies depending on your needs (see more On the other hand, Bitbucket offers a free both public and private way of storing your repositories (Unlimited) and allowing you creating a team up to 5 (free plan: max 5 per team, see more when upgrading team:


Expectations of this article to the reader

You should at least know how to

* perform commands inside the terminal(osx/linux) or command prompt (windows)

* have some basic familiarization how Git Works, read more here:

* develops software application or projects already


Enough of the overview, let start digging in to our basic git commands (using the terminal/command prompt),


1. Setup
Download for Mac:
Download for Windows:
Download for Linux:


2. Initialization of Git Repository (Let’s assume we are on the desktop)
create a new directory
~ md GitTutorial

enter into that specific directory
~ cd GitTutorial

initialize git repository
~/GitTutorial git init


3. checkout a repository (if existing from the remote, or check projects published in
create a local copy of the selected project from your system unit
~/GitTutorial git clone /path/to/repository

create a local copy of the selected project from the remote
~/GitTutorial git clone username@host:/path/to/repository


4. adding and committing files
Basic Workflow: Working Directory > Index (Stage area) > Head (Where files are ready to be pushed into the repository)

Before adding and committing files, you are opt to check if there are any files that has been changed from time to time using the command
~/GitTutorial git status
Red highlighted files are still not added to the initial index, vice versa for the green highlighted files.
To add the files individually,
~/GitTutorial git add <filename>
To add all the files,
~/GitTutorial git add .

After adding the files to the index, you can commit files to the HEAD using the command
~/GitTutorial git commit -m <message>


5. Pushing local files to the repository
~/GitTutorial git push origin master
If you want to push your local files to your remote repository, you should be adding a remote origin first
~/GitTutorial git remote add origin <remote>

These are some of the basic commands to get you started with Git workflow, if you happen trying this on two terminals to connect them:


1. On second computer, clone your repository from the remote.
2. Next is, try editing or creating files on the first computer. Add, Commit, and Push commits on to your remote repository.
3. Try git pull origin master from the second computer to get the latest commits previously made and pushed by the first pc.


The idea behind this bonus section is the workflow environment you will experience if you happen to work with people remotely. When we, Emmanuel Garcia, developed Kaye’s Portfolio, we used Git as our main version control system alongside using Bitbucket as our remote repository.


At first, I’m having hard time taking into considerations the real workflow behind the Git’s magic, but as I have used it with my projects, eventually it became clearer for me how this tech really works.


For Git Cheat sheets, download it here:


If you find this article helpful, please do share it!

Leave a Reply:

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