Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use USB drive as remote

Tags:

I have local copies of a GitHub repo on Laptop and Desktop. The Desktop is ahead of the Laptop and the remote GitHub origin. I want to pull changes onto the Laptop, but don't want to push to the public origin. How do I set up a USB stick/external HDD as a remote?

like image 345
binaryfunt Avatar asked Apr 23 '17 10:04

binaryfunt


People also ask

Can you access a USB drive remotely?

There are many ways to access the USB drive through computer network. In Windows PC you can share the drive and enable Remote Desktop connection. There are also many software available for that, including TeamViewer and USB Redirector. USB Redirector application allows users to access any USB device on a network.

What is a USB remote?

Overview. The USB (Universal Serial Bus) remote control system provides device control via USB, which is equivalent to control via GPIB. Connection is made through an interface in compliance with USBTMC-USB488, USB 2.0 and USB 3.0.

Can you use USB ports with remote desktop?

In most cases, you cannot use a USB device in your client system and in your remote desktop at the same time. Only a few types of USB devices can be shared between a remote desktop and the local computer.


1 Answers

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 
like image 55
binaryfunt Avatar answered Oct 23 '22 06:10

binaryfunt