Search code examples
gitrepositoryworkspace

Local repository with Git


I would like to use Git in my local computer such that, H:\Projects\projectname will be my server-like repository and I would like work by cloning this repo to C:\Users\xxx\AptanaProjects\projectname

How can I do that ?

Thanks


Solution

  • First you need to create a bare repository on H:. With git you usually name your bare repository with .git, so projectname.git in this case:

    h:
    cd \Projects\
    mkdir projectname.git
    cd projectname.git
    git init --bare
    

    When this is done you change to c to create your repository:

    c:
    cd \Users\xxx\AptanaProjects\projectname
    git init
    git add .
    git commit -m "First commit"
    

    After this you need to setup the bare repo on h: as the remote repository so you can push up the code you just commited to the repo on c:

    git remote add origin H:\Projects\projectname.git
    git push origin master
    

    Now, someone else can clone from H: to get your changes, and their repos will automatically be setup with the repo on H: as their origin.