This article describes a short introduction how to setup git and work with it.

First, download and install Git.

The first time you use Git, you have to setup some global config in ~/.gitconfig. The first time it is empty. Add configs with following commands:

You can see all of your settings with this command:


Now, create a new repository at github. Lets name the repository for this tutorial “test”. Then, we need to create a folder called test and init git in this repo. It is always good to create a README file. After that, we will do our first commit and link the folder to the remote repository. The commits are always localy in the created folder, only when the commited code are pushed, then it will be on the remote repo.


The latests command above sets the branch as Upstream. So you can use after this command the following to push it to your repo.


If you have an existing Git repo, you can push it to the remote repo as follows:


Now i will describe some small tips for a better use of Git.

– Create Tags.
Tags are used for versioning of your code. For example V0.1 and so on. Tags are allways created to the last commit. If you want to push the tags, do it 🙂


– Create a new branch.
With the first command, you will create an new branch, the “-b” crates a new branch and set it as start point. The first push you have to do like the second command to push it and set it as Upstream.


– Change to another branch.
If you want to set it as Upstream, you know how to do it 🙂


– Add all files to the Git index or only a file.


– Remove files from the Git index.


– Check the Git status to see in which branch you are and which files are new, witch are modified and so on.


– Check which Git version is in use.


– Ignore some kind of files or folders when you add it to the Git index.
You need a file called .gitignore in the root directory of your created folder at the beginning.


In this file you can know write what you want exclude when you use the command


Here is an example how you can ignore all dist and build folders. Write this in your .gitignore file:


So, you can merge a branch back into for example to master branch: see also link


– Clone a Subversion repository in a Git repository.
You dont need to create the folder for it. Go only i the folder in which you want to create the clone of the svn repo and type the following commands.


In this case it would be useful to check in which branch you are after the clone if there are more.
Checkout the branch you like to use and create then a new branch and push it as a new branch to your repo. So you have a better difference from the original one.


List all tags in your repo:

Delete a tag:

Undo changes in your local Repo, this will override local changes:

Set a branch as upstream

or shorter one

Exlude files temporary from committing to Server:

This is a local setting, and it doesn’t propagate when cloning.

You can undo this with:


Tagged on:     

Leave a Reply


Get every new post on this blog delivered to your Inbox.

Join other followers:

Welcome Damir Kusar

Log in

Lost your password?
%d bloggers like this: