As a follow up to yesterday’s git post, I wanted to share one other Git trick.
SVN is client-server. Git is multi master. Which means that you can easily share your code between your laptop and desktop without ever touching the outside world, though you will need SSH enabled on both machines. Here’s how to do it.
On Your Desktop
git remote add laptop <username>@<laptopname>:/path/to/git/repo git fetch laptop
On Your Laptop
git remote add desktop <username>@<desktopname>:/path/to/git/repo git fetch desktop
Once you’ve got the remote set up, it’s no different than doing a
git pull from the central server.
To pull from the laptop to the desktop:
git pull laptop <branchname>
To pull from the desktop to the laptop:
git pull desktop <branchname>
Never Push in this Case
If you go with this setup, always pull from the other repo. It is never a good idea to push to a repository with an active working copy. Unexpected things can happen and it’s possible to lose commits. Pulling is always safe, since you are actively managing the side that is changing from the operation.
Did you like this? Please share:
The Lost Year: A Failed Experiment to Switch Away From Mac
Fed up with the Apple Keyboard, I bought a ThinkPad, installed Linux, and promptly decided that I hated computers.
Maker's Space, Manager's Space
The Grand Remote Work Experiment: A Retrospective
The COVID-19 pandemic has lead to an unexpected experiment in remote working. What has worked and why?