Jeremy Minton About
Creating Git Repositories
Posted by Jeremy Minton, , 0 comments.

I have recently been thoroughly sold by the benefits of Git. It is a revelation that came slower to me than many of you, probably because I haven’t worked on projects large enough or high risk enough to warrant that sort versioning and I have never seriously been in a situation with that level of collaboration.

Recently, however, I was writing some code to implement a mathematical model I had developed and I decided to invest in properly learning to use git. It almost immediately paid itself off as I could track the many subtle tweaks one makes while chasing sign errors or factors of two as well as using branching to more safely test theories about what may be going wrong. Versioning lends itself to the some-what trial and error processes of this work.

I don’t need to add to the dozens of Git tutorials out there already so instead I am writing this as a reference (to myself mostly) about how to do some typical tasks in git. I will not worry myself with installation or enumerating commands. Although I will mention this site as very accessible instruction of git functionality.

Converting an existing folder to a git Repository

Firstly, create a bare git repository, so on the server (or where you keep your repository)

mkdir <repositoryFolder>.git; cd <repositoryFolder>
git --bare init

Now on your local machine, create a repository out of the current directory and add the bare repository created before.

cd <workingFolder>/..; mv <workingFolder>.bak -R
git clone ssh://[email protected]:/absolute/address/to/<repositoryFolder>.git
cp <workingFolder>.bak/\* <repositoryName>

Then do the usual add, commit, push

git add *
git commit -m "Repository creation"
git push