GIT for beginners guide. GIT tutorial for subversion users

By neokrates, written on July 2, 2010


  • Join date: 11-30-99
  • Posts: 224
View Counter:
Rate it
  • What build management tool does your project or firm use?

    View Results

    Loading ... Loading ...
  • bodytext bodytext bodytext

We begin with one empty GIT remote repository. Repository is called “test-repo” and located under “test-project” project in Gitorious . We will pay no attention to the server side here. We just use the Url to work with remote repo.

Normally, work with Git starts with clone. For Svn user, that is like checkout, we get the source we need. I you have no git, you want to get it first.


✔ Git

✔ Ubuntu 9.10

✔ Gitorious

Should also work for:

✔ Other Git versions git

✔ Other Linux distros and versions

✔ Any git remote server like Gitosis


Get git

Under Linux distros you can simply do:

sudo apt-get git-core


(After I installed it I got with dpkg -l: git-core 1: )

Second option is to go to and take the newest.


Checkout (clone) repository

You need the full Url of remote repository. Given it is your.git.server:test-project/test-repo.git, you do:

git clone git@your_git_server:test_project/test_repo.git test_repo
cd test-repo


git status = svn info

Git status shows the state of your local repository and much more. With status you can learn a lot about Git repository you work on.

git status

You get:

# On branch master
nothing to commit (working directory clean)

That is, your local repository and remote are the same and there are no local changes.


git add = svn add

Create test file:

echo "hallo" > my-file


Trygit status now:

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

Git complains that there is new file and suggest that you add it. That action in Git is called “to stage”.

git add test.file

To add all changes, do:

git add .

💡 svn:

svn add my-file


git status:

# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
# new file: my-file

Git knows about new file and you can commit or reset it.


git reset = svn revert

You have just “staged” my-file. If you didn’t actually want to commit anything you can go back:

git reset my-file

Now you can do some great things with the file or just remove it. In our case we append the file and add it once more:

echo "hali-hallo" >> my-file
git add my-file


git commit = svn commit (“to local repo”)

git commit my-file


💡 svn:

svn commit my-file

💡 Remark:
After Svn commit, central repository has the file. In Git, only local repository has the file. Remote (central) repository knows nothing about it after you commit.

git status:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
nothing to commit (working directory clean)

Here, Git states that your ‘local repository’ is ‘ahead’ of the ‘origin/master’. That means, that your commit didn’t change the master state.


git push = svn commit (“to central repo”)

git push

That will get changes from your local repository to the ‘central’.

💡 Svn does not have this step, all changes go directly to the central repo.

git status:

# On branch master
nothing to commit (working directory clean)

nothing staged, local and remote repos are the same…


git rm = svn rm

git rm my-file

💡 svn:

svn rm my-file


git status:

# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
# deleted: my-file

You can do git commit my-file or git reset my-file as you please now.


Remove remote origin

Maybe your team lead has changed the Git repository location or you need to give your Git project more suitable remote location … First you remove the “current origin”

git remote rm origin



Add remote origin

Can be done for example after “remove remote origin” so that you can work against new remote Url.

git remote add origin


Git push doesn’t seems to work after that, with message like:

warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning: 'nothing' : Do not push anything
warning: 'matching' : Push all matching branches (default)
warning: 'tracking' : Push the current branch to whatever it is tracking
warning: 'current' : Push the current branch
Everything up-to-date

You can now use following to push:

git push origin master (or git push --all)

That’s is, have fun! :)

Be Sociable, Share!

LEARN MORE (amazon bookstore)


Be Sociable, Share!

Leave a Reply