1

The idea is that I want to keep identical local repos with untracked changes across multiple machines with little to no manual intervention. I've thought of and come across a couple different ways of doing this, but each has its own pitfalls.

  • storing the working repo in Dropbox and allowing it to sync (could come across conflicts but in my experience hasn't happened when working alone)
  • committing the changes to a "sync" branch which is then checked out and merged (tedious to deal with the commit history)
  • patchfiles (also tedious)
adhocish
  • 33
  • 3
  • 1
    Can you provide some background as to why you think you need to do this? – Tim Biegeleisen Jan 26 '17 at 05:05
  • I am constantly moving around and developing with multiple laptops and a desktop, and would like to have my working state available from all machines at any time. – adhocish Jan 26 '17 at 05:11

1 Answers1

0

identical local repos with untracked changes across multiple machines

That means:

  • keeping identical repos: that is a post-receive hook in one centralized repo pushing any commit to the other machines. It can work if those other machines are up and accessible from the centralized repo and if there is no concurrent modification done on multiple machines at the same time, but since you are working alone, this is OK.
    If those other machines are not up... a simple git pull from another machine is enough to get back the new commits pushed to a centralized (GitHub ,BitBucket, GitLab, ...) repo.
  • keeping identical working tree: again, for one worker, dropbox could work, provided you keep only the working tree in Dropbox (not the .git, which can quickly become problematic and/or too slow)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I might be misunderstanding the bit about the post-receive hook, but wouldn't that be unable to sync staged commits that have not been pushed to the central repo? – adhocish Jan 26 '17 at 05:23
  • @adhocish no, only committed changes. If you really need to sync staged changes, then you need to sync `.git/index` as well (which is possible, since it is only one file), but not through regular git commands. – VonC Jan 26 '17 at 05:24
  • I see. I've been syncing the working tree along with `.git/` for the past year or so, which accomplishes both tasks but as you mentioned, is possibly problematic. Is syncing `.git/index` all that needs to be done for staged changes? – adhocish Jan 26 '17 at 05:28
  • @adhocish it should work if the repo is not too big, but as my links illustrates, DropBox is not well suited for .git content. – VonC Jan 26 '17 at 05:30
  • @adhocish For staged changes, yes. See also http://stackoverflow.com/a/4086986/6309 and http://stackoverflow.com/a/25352119/6309: you might need .git/objects as well. Which means your initial approach of syncing *all* .git was probably the safest. – VonC Jan 26 '17 at 05:32
  • Okay, point taken. I think I will simply use Dropbox to sync the working tree and forego attempting to sync staged changes (which doesn't happen too often anyway since they are generally pushed immediately). Thanks for your insight! – adhocish Jan 26 '17 at 05:36