git with "local" remote rep

Discussion in 'Mac Programming' started by SchodMC, Aug 25, 2013.

  1. macrumors member

    Joined:
    Jul 29, 2013
    Location:
    Germany
    #1
    Hi guys,

    Using Xcode with git seems to be a really fine solution. But there is one thing I couldn't figure out how to make it.

    I want to create a remote repository on an external USB drive, so that I can push my work to the USB drive from time to time to have an external backup. So I created an new repository on my USB drive using the command "git --bare init" inside the folder where I want to store that repository. Then I switched to my projects directory and added the folder with "git remote add TestAppExternal file://Volumes/External/git\ repositories/testapp/". Everything goes fine, but when I want to push my repository to the "remote" repository on my USB drive using the command "git push -u TestAppExternal master", I got the following error message:

    fatal: '/External/git repositories/testapp/' does not appear to be a git repository
    fatal: Could not read from remote repository.

    So - what I'm doing wrong? Will be nice if someone can help me here.

    cu
    SchodMC
     
  2. macrumors regular

    Joined:
    Jun 26, 2013
    #2
    Don't use file:// when you do git remote add

    Remove the current remote repo and do:

    Code:
    git remote add TestAppExternal /Volumes/External/git\ repositories/testapp/
    Just tested real quick - when you add file:// it makes it think the external HD is relative to root, rather than relative to /Volumes. Not entirely sure why - seems like it may be a bug.
     
  3. thread starter macrumors member

    Joined:
    Jul 29, 2013
    Location:
    Germany
    #3
    Hey - that works. Even Xcode will now accept the remote repository for push / pull operations. Thank you very much.

    cu
    SchodMC
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    Try it with 3 slashes, e.g. file:///Volumes/External/pathname.

    Or try file://localhost/Volumes/External/pathname.

    The OP's error message was:
    Code:
    fatal: [COLOR="Red"]'/External/[/COLOR]git repositories/testapp/' does not appear to be a git repository
    
    To me, this looks like the //Volumes part is being interpreted as a hostname, which is correct according to the latest RFCs.
    http://en.wikipedia.org/wiki/File_URI_scheme#Format
    Note that when omitting host you do not omit the slash ("file:///foo.txt" is okay, while "file://foo.txt" is not, although some interpreters manage to handle the latter).​
    Also see the "Examples" section for examples.
     
  5. macrumors regular

    Joined:
    Jun 26, 2013
    #5
    That explains it. Thanks.
     
  6. thread starter macrumors member

    Joined:
    Jul 29, 2013
    Location:
    Germany
    #6
    Just tried it out with file:/// and file://localhost/ - both worked fine. Learned an other thing - thanks for that. ;)

    cu
    SchodMC
     

Share This Page