Create a git repository on a server with ssh access

Here is a simple way to set up a git repository on a server with ssh access.

1. Init the empty repository on the server

Instead of creating a bare repository locally, transfer it to a git server and delete the local copy afterwards, i create the (empty) git repository on the server itself (which requires shell access via ssh).

thomas@gitserver:/home/git$ mkdir <projectname>
thomas@gitserver:/home/git$ cd <projectname>/
thomas@gitserver:/home/git/<projectname>$ git --bare init --shared
Initialized empty shared Git repository in /home/git/<projectname>/

I still don't remember the mandatory order of these options…

2. Connect the local git repository with the newly created server repository

The local git repository has to be created.

thomas@local$ git remote add origin thomas@gitserver:/home/git/<projectname>

Now the local and remote repository are connected.

3. Initial upload of content

Now we can push our local created content (branch master) to the server repo.

thomas@local:/home/thomas/<projectname>$ git push origin master
Counting objects: 67, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (56/56), done.
Writing objects: 100% (67/67), 79.96 KiB, done.
Total 67 (delta 10), reused 0 (delta 0)
To thomas@gitserver:/home/git/<projectname>
 * [new branch]      master -> master
4. Connect the master branch for pull

Finally you have to tell git which branch to pull:

thomas@local:/home/thomas/<projectname>$ git remote set-branches origin master


OS X Tip - Avoiding '.ds_store' Files on Network Drives

Mac OS X by default leaves behind a file named '.DS_Store' in every directory that is opened on a Non-Mac filesystem using the Finder application. This is especially annoying on network drives and external media like Compact Flash or SD cards.

What is in those files? Finder uses them to store meta-data about its display of the folder, like the current display mode, position and order of Icons etc.

However, not only do I find those files annoying, I don't even necessarily want to preserve the order or position of the icons in a folder display. I'd much rather have the view reset the standard when I reopen the folder.

Luckily, it is easy to prevent the creation of said files on remote storeage drives.

To this end, just run the following command in the Terminal window:

defaults write DSDontWriteNetworkStores true

The setting takes effect from the next login, and is specific to the user account the 'defaults' command is executed as. Consequently, it is best to repeat the setting for all user accounts.

By the way, here is the link to the original post from Apple that lead me to this solution:

Unfortunately, the entire thing only works for network drives at this point. I am still looking for a solution for local drives…