How to use USB drive as remote

Plug the USB drive into Desktop, and assuming it’s showing up as J:

  1. Initialise a bare repo that will act as the remote:

    git init --bare J:\repo_name
    
  2. cd to the local repo and:

    git remote add usb J:\repo_name
    git checkout master
    git push usb master
    

The master branch is synced with the usb remote. Now plug the USB drive into Laptop, and assuming it’s showing up as D:

git remote add usb D:\repo_name
git checkout master
git pull usb master

If you’re trying to pull a branch that doesn’t exist on Laptop but does on Desktop, you can just do git checkout the_branch and it will automatically pull it from usb (unless the_branch also exists in origin, in which case you have to do git checkout -b the_branch usb\the_branch)

You might have to git fetch if it doesn’t find the remote usb branch.

If, later, you plug in the USB drive and it shows up as a different letter, e.g., K:, then do:

git remote set-url usb K:\repo_name

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)