Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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 connection to the outside world?

(User @bee and I actually have that problem as I type this, though obviously not as I send this. In our case we both have Mac laptops -- OSX Snow Leopard -- but I think it would be better to treat this question generically.)

like image 704
dreeves Avatar asked May 10 '11 09:05

dreeves


People also ask

Can I use git without internet?

When working off line, two Git tasks cannot be performed: fetching/pulling updates from the server, and pushing changes to the server. All other commands still work. One can commit changes, branch off, revert and reset changes, the same as when there exists an internet connection.

Can I have two remotes for git?

You can add multiple remotes by using git remote or git config commands or editing the config file.

Does git push push to all remotes?

The objective is to push to multiple Git remotes with a single git push command. If you don't want to create an extra remote named all , you can skip the first command and use the remote origin instead of all in the subsequent command(s). Now, you can push to all remote repositories with a single command!

How do I add a second remote to git?

To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A unique remote name, for example, “my_awesome_new_remote_repo” A remote URL, which you can find on the Source sub-tab of your Git repo.


1 Answers

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
like image 127
KingCrunch Avatar answered Nov 15 '22 19:11

KingCrunch