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.)
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.
You can add multiple remotes by using git remote or git config commands or editing the config file.
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!
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With