Search code examples
gitclone

cloning git repository on thumbdrive


I already have a local workig space repository in /applications/mamp/htdocs/myproject/.git and i can't figure out how to clone it onto a folder in my thumbdrive and use that as my remote to push to.

do i have to create a bare git repository in the directory on my folder first? and then clone my working space one to it?

or do i just cd into my directory on my thumbdrive(with no .git directory) and clone the working space repo to it which would automatically create the .git repo on the thumbdrive?

i'm confused on the proper steps to use my thumbdrive as my remote repo

my thumbdrive's path is "volumes/thumbdrive/"

now i'm trying to add my remote but i can't seem to get the path right i guess...

David-Adamss-MacBook-Pro:myproject davidadams$ git remote add flashstick /volumes/thumbdrive/repo/.git
David-Adamss-MacBook-Pro:myproject davidadams$ git remote
flashstick
thumdrive
David-Adamss-MacBook-Pro:myproject davidadams$ git push flashstick master
fatal: '/volumes/thumbdrive/repo/.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

and this didn't work either

David-Adamss-MacBook-Pro:myproject davidadams$ git remote add flashdrive /volumes/thumbdrive/repo
David-Adamss-MacBook-Pro:myproject davidadams$ git remote
flashdrive
flashstick
thumdrive
David-Adamss-MacBook-Pro:myproject davidadams$ git push flashdrive master
fatal: '/volumes/thumbdrive/repo' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
David-Adamss-MacBook-Pro:myproject davidadams$ 

Solution

  • Clone the local repository into your volumes/thumbdrive and then setup remotes to this newly cloned repo from the old one

    `git remote add thumbdrive volumes/thumbdrive`
    

    The remote name after above would be thumbdrive ( use origin if you want ) and you can push like

    `git push thumbdrive master`
    

    Another approach:

    Copy / move /applications/mamp/htdocs/myproject/.git to the thumbdrive and then clone it back to the desired location.