Creating Git Repositories
Posted by Jeremy Minton, 9 years ago ,

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.

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. 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 REDACTED]:/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

Posted Saturday 4 October 2014 Share

- You might also like:

- Frequentist hypothesis testing
- Fixing ctrl+arrow to jump words in Alacritty terminal.
- Developing in Docker containers