How two laptops can git push/pull to each other with no internet

后端 未结 5 1715
情话喂你
情话喂你 2020-12-24 03:05

Say my co-hacker and I find ourselves on a desert island. Normally we push and pull to github to sync with each other. How would you recommend we do so when we have no conne

相关标签:
5条回答
  • 2020-12-24 03:36

    One solution compatible with your scenario would be to share through an USB stick one file through git bundle

    That allows you to:

    • consider that one file (the 'bundle') as an upstream repo to which each user can update said bundle, and from which they can fetch new commits.
    • avoid trying to synchronize a large collection of files/meta data within a bare repo structure.
    • don't rely on any network/server process whatsoever.
    0 讨论(0)
  • 2020-12-24 03:47

    Take a SD-Card, or an USB-stick or something. Create a bare repository there. Then one push to that repo, unmount the card/stick, give it to the other, that one pull from it.

    cd /path/to/usbstick
    mkdir repo
    cd repo
    git init --bare
    cd /path/to/local/repo
    git remote add usb /path/to/usbstick/repo
    git push usb --all
    

    One the other machine

    cd /pat/to/local/repo
    git remote add usb /path/to/usbstick/repo
    git fetch usb --all
    
    0 讨论(0)
  • 2020-12-24 03:47

    For starters - get this book - http://book.git-scm.com/

    Indispensable

    Second, there is a section on page 40 titled Distributed Workflows

    That should cover what you need, just use ssh as your comms protocol (assuming you're familiar with ssh from command line)

    0 讨论(0)
  • 2020-12-24 03:49

    Running a git server locally should work if you're on the same network. One would push to his own machine, the other to the other machine (based on local IP).

    0 讨论(0)
  • 2020-12-24 03:53

    The simplest solution is probably to just set up an ad-hoc wireless and SSH to eachother's laptops. You can set up your remote with

    $ git remote add cohacker myuser@cohackers-laptop:/path/to/repo.git
    

    Now you can push/pull to your heart's content:

    $ git pull cohacker master
     ... hack away ...
    $ git push cohacker master
    
    0 讨论(0)
提交回复
热议问题