如何将USB驱动器用作遥控器 [英] How to use USB drive as remote

查看:136
本文介绍了如何将USB驱动器用作遥控器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在笔记本电脑和台式机上有GitHub存储库的本地副本.桌面位于笔记本电脑和远程GitHub origin之前.我想将更改放到笔记本电脑上,但是不想向公众发布origin.如何将USB记忆棒/外部HDD设置为遥控器?

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?

推荐答案

将USB驱动器插入桌面,并假定其显示为J:

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

  1. 初始化一个裸仓库,它将充当远程仓库:

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

git init --bare J:\repo_name

  • cd到本地存储库,并:

  • cd to the local repo and:

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

  • master分支与usb遥控器同步.现在,将USB驱动器插入笔记本电脑,并假设它显示为D:

    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
    

    如果您尝试拉出笔记本电脑上不存在但台式机上不存在的分支,则只需执行git checkout the_branch,它将自动从usb中拉出它(除非the_branchorigin,在这种情况下,您必须执行git checkout -b the_branch usb\the_branch)

    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)

    如果找不到远程USB分支,则可能必须git fetch.

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

    如果稍后再插入USB驱动器,并且它显示为另一个字母,例如K:,则请执行以下操作:

    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
    

    这篇关于如何将USB驱动器用作遥控器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆