Tuesday 25 September 2012

Create a new Git remote repository on a windows network share

I've created remote repositories a few times on a network share, but each time I'd spent too many hours trying to recreate my steps. Most of the google posts seem to come from non-windows users so doesn't help me much. If you are a windows/git user I'll show you how to achieve this in a few easy steps.

In the command prompt navigate to the network share directory making sure all required permissions are set and issue the following command.

git init

Next create a dummy file e.g. a README.txt file in the remote repository and commit this file.

git add -A

git commit -m 'Initial cimmit'

This will make the repository a non empty non bare repository and force the creation of the master branch. Now navigate to your local folder and clone the remote repository with the following command.

git clone "network share directory/working directory"

Navigate back to the remote repository and set the following config

git config --bool core.bare true

Now you can resume normal business by working in your local folder and when ready to commit to the remote repository, do the following


git add -A
git commit -m 'Added some good code'
git push origin master

Happy coding!!!.