Adrian Andreias

Jan 18, 2013

my git reminder

(to be updated)

1. Create the local git repository

Even if you don't plan to use a git server and only store files on your localhost you should create a git repository as early as possible because:

  • you will have a file editing history, provided that you'll commit frequently
  • it only takes a few seconds to create a git repo

(Note that "git commit" means something slightly different than "svn commit". Since svn always assumes having a svn server, git can be used just on your local file system, a git server is not mandatory. Git will keep track of your changes in his internal database stored in directory .git by default. git push would be the equivalent of svn commit, that is publishing changes to a server).

Without further ado:

  1. git init # this will create the git database under directory .git from current path
  2. create file .gitignore. This contains the list of files that will not be added to git database. Here's what mine usually contains: .idea *.pyc
  3. git add * # to add all files
  4. git commit -a # to commit all files

Read more in the git book.

And GIT for SVN users:

2. Initial server push

Once you have the local git repository you'll want to publish to the git server.

  1. Create the repository on your git server:

    cd /var/repos mkdir myproject.git cd myproject.git git init --bare
  2. Add remote server:

    sudo git remote add origin
    ssh://<git user>@<git server>/var/repos/myproject.git
  3. and push your local repository to remote server:

    sudo git push -u origin master


posted at 10:44 ·  · git