Asked

How do you synchronize projects between laptop(s) and desktop?

I have a couple of machines I use for development - home desktop, laptop and office. I was using Git on its own but kept forgetting to commit files before leaving the house, so I moved all my code into Dropbox to sync between machines.

This worked pretty well until I started using front-end tools - now it seems anytime I need to add hundreds of tiny files using npm install or similar the combination of Windows Anti Malware and Dropbox cause massive CPU churn for what should be a pretty simple operation.

Is there anything I can do to speed this up, or a more sensible way to sync folders?

I moved away from Dropbox because it couldn't deal with node_modules, it would just be syncing for hours. You could exclude the folder, but that's just tedious to do for all your projects. They don't support exlusion patterns, something like .dbignore would be amazing but are unresponsive to requests. See this topic from 2014.

I've canceled my Dropbox Pro and moved to STACK which does support ignore patterns ( it's is a Dutch service, files are stored in The Netherlands ( which to me is a plus as well ) ). I'm not sure if it's available for customers outside of The Netherlands.

Someone posted a link to Resilio Sync in Dropbox topic, they apparently also support ignore patterns.

Thanks Rik, yes that's precisely the problem - 90,000 tiny wee files in a node folder for each project, plus composer's vendor etc. I think I need to get better at workflows too TBH, as it's not uncommon for me to sit down and get stuck on a bug for x minutes without realising I forgot composer install or similar.

Nowadays I tend to use just the one device (MacBook Pro), but I still choose to use Git. Some of the benefits for me:

  • Saving incremental changes so I can easily revert back in case any problems arise. This also gives me more confidence to experiment within my code.
  • Being able to create branches also lets me experiment with new ideas without the fear of messing up my code.
  • Let's me use Continuous Integration that automatically runs my tests and rubocop (checks for coding style violations)
  • I can access my code everywhere. More than once I've fixed a wipbot bug on my iPhone! (pull code the code, make the fix, push the change)
  • It makes it easy to collaborate with other developers now and in the future
  • The commits are a way to document your code. So if in a year time you're wondering why you made a certain change, you can quickly find it.
  • My code is backed up in multiple places at every stage
  • Any merge conflicts are handled automatically when possible or are relatively easily managed manually (versus syncing app that are not optimized for code)

Using Git does indeed come with the requirement of committing and pushing your code. I believe it's a habit worth developing though for the reasons above. There are also some tools you can use to make this easier. For example my Terminal is set up such that it shows when there uncommited or unpushed changes in my working repository.

Do you plan on writing code for the foreseeable future? If so, then I recommend investing in a workflow that will let you reap the rewards long-term.

Excellent answer, thanks Marc. I only started using Git about 18 months ago and though its now an established part of my workflow I'm definitely not using it to its full potential at all. I largely use it for 'i finished, push to production' and only when i remember to for 'heres a good place to save my work'.
It's probably time I worked my way through a course to make better use of branches etc. And probably time I wrote some tests too! :D

> The commits are a way to document your code. So if in a year time you're wondering why you made a certain change, you can quickly find it.

I thought this was a really interesting bullet. Does this mean you try to include the 'why' in your commit messages rather than just 'fixed xyz / added abc' type notes?

> It's probably time I worked my way through a course to make better use of branches etc. And probably time I wrote some tests too! :D

Haha yeah, but take it one step at a time. I feel like I haven't even scratched the surface of Git myself. But whenever I encounter a problem or notice I keep doing the same thing over and over again, I look for ways to improve my workflow. It seems like you just hit one of those issues yourself (hence the question).

> Does this mean you try to include the 'why' in your commit messages rather than just 'fixed xyz / added abc' type notes?

Only if I feel like it's needed. I have plenty of "fix foo", and "add bar" type of messages though. It really depends on the circumstances. But just having every incremental change accessible separately by itself is already very valuable. For example you can go to a specific line of code and see all previous commits that touched it. So if you wonder why a piece of code is the way it is, you can just look up those commits which will help you jog your memory.

an end-to-end encrypted filesystem like s3ql or a commercial offering like objectivefs. i use the latter from multiple machines, works like a charm. i store my git repos on there and periodically push to GitHub. working on a remote filesystem has its drawbacks, too, it can get especially slow when you have high latency or are working with large files.

Sign in to answer πŸ˜ƒ