Copying a git repository to USB drive

后端 未结 4 1023
暖寄归人
暖寄归人 2021-02-13 17:27

I am working on an Open Source project and I have a git repo on my machine with all the code. The repo is kind of big, and I would like to keep working on it while I do not have

相关标签:
4条回答
  • 2021-02-13 17:41

    It will work, but certain config variables won't travel with you.

    Git has three levels of configuration: system-wide (all users on a PC), global (user-specific) and repo-specific.

    The repo-specific configs will move around with your repo; the system and global configs won't. I would check your config files and if necessary also grab a copy of your user-specific configs.

    0 讨论(0)
  • 2021-02-13 17:46

    I kinda don't like the idea of copying git repositories from one place to another. Instead, I absolutely would recommend using a remote server for your code.

    There's at least 2 excellent git as service around: the most famous is GitHub, which will freely host your code if you don't mind sharing it in a public repository. If you want to keep it private and don't want to pay for it, go for BitBucket.

    0 讨论(0)
  • 2021-02-13 17:56

    The best way is to add a remote (even though it's a local folder). In this way you can always transfer commits between the two. When you want to move

    git init /mnt/usb/repo
    git remote add usb /mnt/usb/repo
    git push usb master
    

    The last command can be used to push any branches into the folder as desired. If the local branch has no remote currently set as upstream you may have to do --set-upstream.

    See also git how to add a local repo and treat it as a remote one on Stack Overflow.

    0 讨论(0)
  • 2021-02-13 18:00

    I was facing the same situation as you. After some digging, I cloned the repo onto my usb drive, then cloned the repo from the usb to the other computer; and then changed the remote for the repo on the new computer using: git remote set-url origin

    You can make sure the origin you added is correct using:

    1. git remote -v, or,
    2. git log, to make sure you can see the commits made on the original repo
    0 讨论(0)
提交回复
热议问题