Search code examples
gitsvnversion-controlmercurialtortoisehg

Specifying where Version Control repositories are stored


I'd like to use VC for development projects, however what I see in the various types (Git, SVN, Mercurial...) doesn't seem to suit what I'd like to accomplish.

What I'd like to do is have the code repositories stored on an external device (such as thumb drive or SD card), not only for version control, but also as a backup in case my local hard drive crashes.

After reading some tutorials on the various VC packages, I'm having some difficulty understanding how that could be accomplished. Most of what I see is the repository has to be initialized in the root directory of the project's directory structure, and that's not where I'd like the repositories to be stored.

It seems to me this creates duplicates of code...
Or am I just missing something ?
Can this be accomplished ?

Any help understanding this is greatly appreciated !


Solution

  • Since Git is decentralized, you can have:

    • a local repo on your disk where your sources are
    • a bare repo on your thumb drive, where you are pushing your sources to, for backup

    That is:

    cd /path/to/myproject
    git init .
    git add -A .
    git commit -m "my sources"
    

    Then

    cd /path/to/thumdrive
    git init --bare myproject.git
    

    Finally

    cd /path/to/myproject
    git remote add origin /path/to/thumbive/myproject.git
    git push -u origin master