Sunday, 25 January 2015

Post 21: How to Git?

Git is a versioning tool. Everything you pushed to Git can be recreated. Having said that Git is used to collaborately work with other developers and share your code. It's also a good cloud storage for your (general) files.  So, Git can basically used for any kind of projects - not only software projects.

Head up: If you want to keep your files private you have to pay a fee each months. If you're using the Free version then all your files will be publicly accessible.

The installation process I describe here is for Ubunut 14.04 but works well in all other Debian based Linux distrobution I guess.Open up the terminal and type in the following command:

sudo apt-get install git 

Before you start configure your settings: If your name is Bob Dole and you have an email address like then type in these lines (after each one press <enter>):
git config --global "Bob Dole"
git config --global

0451. git config --global "Derek Banas"
0472. git config --global
0493. git config --global core.editor "vim" # Set editor as vim
0514. git config --global core.editor "edit -w" # Set editor as Text Wrangler
- See more at:
After that, create an account on Chose a user name (e.g. "bobdole") and a password. Now you want to create a repository by clicking on the "+" sign next to your user handle. Give it a repository name, e.g. "testRep" and click on the button "Create repository".

Ok, now go back to your terminal.

Below I'll show you the most important git commands. First create a project by creating a folder: Go to the directory where you'd like to store your project folder. You can use

cd [folder name]

in order to go to the folder called "folder name" or you can use

cd ..

in order to step out of the current folder you're in.

Once you are in the directory of your choice, initialize your project folder:

git init
Now you have to connect your repository you created on with the local project folder.

git remote add origin 
Of course your project folder has to contain something. As an example I'll just create a read-me file:

git add

Now whenever you want to synchronize your remote folder (the one on GitHub) with your local one you have to type in the following commands. If you're collaborating with mulitple users or working on your project different computers you have to first synchronize your local project folder with the remote one:

git pull
After that you have to add your changes. In order to keep in simple let's just add all files you created:

git add --all
Next you can add comments to the changes you made:

git commit -m "I made some changes"
Now the remote folder on GitHub should be the exact copy of your local one. In order to do that execute the following command line:

git push -u origin master

After that you'll be asked to type in your GitHub user name and password. If the push was successful it will say something like

u0d25d07..46baad4  master -> master

Now that you have pushed your project other people or you yourself can access it on a different computer. In order to do that you have to clone the project onto your computer:

git clone
If you want to remove your remote repository, type in this:
git remote rm origin