Git Quick Reference

Git is the most useful tool for developers but if someone does not use it for a while, it all seems confusing. Git is tricky. Here are some of the most commonly used command.

Installing git

$sudo apt-get install git

Create new git repository

$git init

Create git repository on server

$git init --bare

Please note the difference : A bare repository is a git repository without a working copy, therefore the content of .git is top-level for that directory.

Use a non-bare repository to work locally and a bare repository as a central server/hub For example, when you create a repository on, it is created as a bare repository.

To conclude, the repository on the server side is going to get commits via pull and push, and not by you editing files and then committing them in the server machine, therefore it is a bare repository.

You can push your changes from local to remote by using following command

$git remote add live ssh://

once this is added you can check all remotes using following command

$ git remote -v
live ssh:// (fetch)
live ssh:// (push)

Deploying the changes.

Once your changes are ready, you can deploy it using following commands

git add .  
git commit -m "commit comment"  
git push live master  

Copy remote repository to your local folder.

$git clone ssh://  

To get list of files changed in directory

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: MySQL/

Untracked files:
(use "git add <file>..." to include in what will be committed)

MS Excels/

no changes added to commit (use "git add" and/or "git commit -a")

Get commit history

$git log



Leave a Reply

Your email address will not be published.