Revisioncontrol with Git

The most fundamental difference between Git and other revision control systems like SVN or CVS is the way how you work with it. With Git you will usually clone a repository. This creates a directory on your desktop where all the data about all revisions is stored. This means that you are not depending on a server somewhere. You can easily just use git locally.

Local install

Most current linux distributions include a package git-core and maybe also git-gui If you are using Windows you should have a look at msysgit

After the initial install you should configure the your user information:

Install on a server for example QNAP NAS TS-209

You can just install git the same way as with the local install. On a TS-209 this means:

You can create a repository on the server as follows:

with –bare your files will just be saved in the binary git-format.

To use that repository on the local machine you will need to create an empty repository and the you can specify the remote one as a remote destination. The command push allows you to writer local changes onto the server and fetch allows you to read updates from the server and apply them locally.

Full syntax for SSH-Url:


Caution: you cannot define the password for the user (not user:password@SERVER:PORT) if you define a port!

Using git for a SVN-Repository

Usually you just need to install the package git-svn. After that you can use a SVN repository just the same way as you would use a git repository. You just need to type git-svn instead of git for all commands.

Import an SVN repository:

Fetch updates

Ignore filemode changes

Just execute the following command:

Problems with git

  • Trailing Whitespace Error
    This pre-commit Error can be fixed easily. Just remove the following lines from the file .git/templates/hooks/pre-commit:

  • git-receive-pack: command not found

    The reason for that error is the PATH variable which will not be set if you are using a not-interactive SSH connection. For an easy fix you could just make links to the necessary binaries in you /bin folder:


C# Performance/Memory Pitfalls

Some things you could look for in the code

  • Lists vs Queues: If you loop over a list the Garbage Collector cannot free memory even if you just need to process each object once. Use a Queue instead as soon as the object is removed and processed it can be garbage collected
  • MemoryStream: You shouldn’t construct MemoryStreams with the default constructor. This will result in a stream for 128 kb of data. Internally the data is saved in a byte array and as soon as you exceed the 128 kb if will allocated twice the old amount and it needs to copy the old content. If you know that you are writing about 64 mb of data you should therefore initialize the MemoryStream with that capacity. Otherwise it will need to expand itself 10 times. You will also end up with objects that are wasting space (32 mb, 16 mb, 8 mb, 4 mb, 2 mb, 1 mb, 512 kb, 256 kb, 128 kb). All these objects need to be garbage collected and if you are using MemoryStreams frequently you will generate big areas of non-continuous space and after a while C# will not be able to allocate big objects (arrays need continuous space!) anymore.
  • ArrayList: Quite the same as for MemoryStreams. Initialize them with a reasonable capacity

Where to optimize: Usually most of the time that a method takes is just in very few lines. A big refactoring is usually not worth the effort. Pay attention:

  • to use the right datastructure: p. x. never try to search elements in an unsorted list)
  • to use the right algorithm: BubbleSort is only efficient if the data is almost sorted
  • to use caching: if you need to access a calculated value a lot just save it in a member after you calculated it the first time but pay attention to invalidate the cache
  • to optimize the database access: do you really need distributed transactions?, use a connection pool, use one query to fetch all the data you need (and maybe a little bit more) instead of lots and lots of small queries