gitbackupgit-remotebackup-strategies

How do I use git without having a proper git server?


I want to be able to make backups of my project in a windows environment without having to manually copy and paste my whole folder. Unfortunately I am not allowed to use a remote git server for this project, so I was wondering if I could use git for backing up my project on a mounted hard drive.

I have tried this solution:

git remote add Y file:///path/to/Y

However, when I try to push I receive this error:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried to init a bare repository on my mounted device and local directory but I faced the same error.

Summarizing, I want to be able to backup my project in a windows environment automatically or with few commands such as git commit and git push. Any ideas?


Solution

  • Here is what I did and what as far as I know works:

    First you create a git repo:

    cd e:/tmp 
    mkdir backup
    cd backup
    git --bare init
    

    Now the git repository was created you need to go to your files.

    Let's say you use xampp and you want a backup from one of your projects.

    cd e:/xampp/htdocs/project
    git init
    git add .
    git remote add backup e:/tmp/backup
    git commit -m "First commit"
    git push backup master
    

    Boom now it saved everything into your backup into master branch ;) You can even do it in different HDs... that's how I keep code tracked at home 4 free into my backup HD.

    Hope this help someone else in future as well.

    See ya! ;)