catchablepaper
catchablepaper

Reputation: 63

GitHub Dropbox - best way to sync between computers?

How should I best sync a GitHub repo that is also synced on Dropbox between two computers?

I had an old computer that does not power on, which had a GitHub repo that was also a Dropbox folder (so everything in it was backed up to my Dropbox).

I now have a new computer, which after I synced to Dropbox, has the entire repo. However, it is not linked to my GitHub Desktop (i.e. my GitHub Desktop application does not recognize it).

Is there a way to make GitHub Desktop recognize the Dropbox folder on my new computer as a Git repo and sync to GitHub?

Upvotes: 4

Views: 1035

Answers (2)

Mark Rejhon
Mark Rejhon

Reputation: 909

For GitHub + Dropbox + Git:

If your priority is worktree syncing between your own machines:

I solved my problem by forcing Dropbox to ignore my .git subfolders.

That syncs my personal worktrees, while leaving github alone. Be careful about how it works though, and only do it only for your own account (e.g. your own PC and your own laptop). I simply have to re-pull from my other machine (directly from github) when I push from one machine, to make sure that the git data is in sync with each other.

It behaves as if you copied over the files manually via thumbdrive (excluding .git), so make sure you re-pull git everytime you switch machines. And always remember to switch branches on both machines manually, every time you switch branches.

Instructions for Windows (run in PowerShell):

Set-Content -Path 'C:\path-to-project-inside-dropbox\.git' -Stream com.dropbox.ignored -Value 1

Instructions for Mac:

xattr -w com.dropbox.ignored 1 /path-to-project-inside-dropbox/.git

Instructions for Linux:

attr -s com.dropbox.ignored -V 1 /path-to-project-inside-dropbox/.git

It's convenient when you have a lot of data/logs/object files/etc (anything big in .gitignore but you let sync in Dropbox, as LAN sync is fast enough to sync the big stuff).

Dropbox syncing all the data and object files allows faster compiles of larger projects on both owned machines after minor modifications (for same-OS x64), and easier comparative testing on the other machine.

And keeps github unpolluted.

This is better than the selective sync system because of all the automatic "selective sync conflicts". This method forces Dropbox to completely ignore everything in specific subfolders, as if it didn't exist.

And if you mess up, you also have a double backup of github and Dropbox to rewind to (both have separate convenient recovery use cases, like resurrecting specific logfiles).

Upvotes: 0

VonC
VonC

Reputation: 1330092

So you are saying the best bet in this case is to delete the folder in Dropbox and clone it from GitHub fresh?

What you can push in Dropbox is a bundle (using the git bundle command): that will be one file (easy to synchronize), from which others can clone/pull from: it acts as a "remote".

Plus, it won't include your local configuration (which might have sensitive information)

Upvotes: 1

Related Questions