{"thread":{"id":"37147","subject":"Syncing Git Repositories","startedAt":"2014-07-17T02:26:07Z","lastAt":"2014-07-17T16:35:24Z","messageCount":3,"participants":["Sajan Parikh","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"246213","messageId":"53C7343F.4090806@parikh.io","threadId":"37147","inReplyTo":null,"subject":"Syncing Git Repositories","fromName":"Sajan Parikh","fromEmail":"sajan@parikh.io","sentAt":"2014-07-17T02:26:07Z","receivedAt":"2014-07-17T02:26:07Z","isPatch":false,"sender":{"key":"sajan@parikh.io","avatar":null},"body":"On all my laptops and desktops, I have a directory at /home/sajan/Code \nwhere all my active projects and repositories live.\n\n/home/sajan/Code/repository1\n/home/sajan/Code/repository2\n/home/sajan/Code/repository3\n\n...etc...\n\nUp until now I've relied on pushing and pulling to and from my Gitlab \nserver to keep my projects in sync across all my laptops and desktops.  \nIt's worked great.\n\nHowever, today I decided to add my code folder to my ownCloud server and \nsync it across all my laptops and desktops the same way I do for \n/home/sajan/Documents, /home/sajan/Music, and a few application config \ndirectories to keep all my devices in sync.\n\nBy syncing my code folder and git repositories in this way, do I risk \nborking any repositories?  I'm 99% confident I'm not, since everything \nis in .git/, and there are not external databases or log files that need \nto be updated.  Just making sure though.\n\nI'm only doing this because sometimes I forget to pull changes down from \nmy Gitlab server on a different laptop or desktop and start making local \nchanges.  Which is fine, I can merge easily, but if everything were \nsync'd automatically when I logged into my computer it would be great.\n\nAnother option I thought of would be to write a bash script that \nexecuted at login and went into each of my repositories and ran git \npull, but I decided against this because of legitimate non-fast-forward \nmerges.\n\nTLDR;\n\nIf I sync my repositories across computers using something similar to \nDropbox, rather than pushing/pulling to and from an central repository, \nam I risking borking any respository?\n\n-- \nSajan Parikh\n\n\n"},{"id":"246216","messageId":"vpqwqbcv5m0.fsf@anie.imag.fr","threadId":"37147","inReplyTo":"53C7343F.4090806@parikh.io","subject":"Re: Syncing Git Repositories","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-07-17T06:53:11Z","receivedAt":"2014-07-17T06:53:11Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Sajan Parikh <sajan@parikh.io> writes:\n\n> By syncing my code folder and git repositories in this way, do I risk\n> borking any repositories?  I'm 99% confident I'm not, since everything\n> is in .git/, and there are not external databases or log files that\n> need to be updated.  Just making sure though.\n\nYou're right that there are no external database, hence if you actually\nsync the whole worktree+.git/, you won't have any problem.\n\nI synchonize a bunch of Git repositories between machines with Unison\n(file transfer utility), it works great.\n\nOne issue you may encounter is if you have either partial\nsynchronization (e.g. network loss in the middle of a synchronization, I\ndon't know how owncloud deals with it), or two way synchronization\n(there's a synchronization between your laptop and owncloud ongoing, and\nyou start working on your desktop and trigger a synchronization.\n\nI sometimes encounter this situation with unison. The good news is that\nin 99,999% of cases where I'd encounter a problem, Unison shows a\nconflict on the index file (modified on both sides). So, in these cases,\nI just use Git normally to synchronize, decide that one side becomes the\nreference, and rsync to the other to resolve the Unison conflict.\n\nAlso, you have to ensure that you synchronize both file\nadditions/modifications, and file deletions. I often make the mistake of\nusing rsync without --delete, and it confuses the branch storage format\n(I keep my local unpacked branch, and the packed branch is hidden by\nit).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"246250","messageId":"xmqq61iwq6yb.fsf@gitster.dls.corp.google.com","threadId":"37147","inReplyTo":"vpqwqbcv5m0.fsf@anie.imag.fr","subject":"Re: Syncing Git Repositories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-17T16:35:24Z","receivedAt":"2014-07-17T16:35:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Sajan Parikh <sajan@parikh.io> writes:\n>\n>> By syncing my code folder and git repositories in this way, do I risk\n>> borking any repositories?  I'm 99% confident I'm not, since everything\n>> is in .git/, and there are not external databases or log files that\n>> need to be updated.  Just making sure though.\n>\n> You're right that there are no external database, hence if you actually\n> sync the whole worktree+.git/, you won't have any problem.\n>\n> I synchonize a bunch of Git repositories between machines with Unison\n> (file transfer utility), it works great.\n>\n> One issue you may encounter is if you have either partial\n> synchronization (e.g. network loss in the middle of a synchronization, I\n> don't know how owncloud deals with it), or two way synchronization\n> (there's a synchronization between your laptop and owncloud ongoing, and\n> you start working on your desktop and trigger a synchronization.\n>\n> I sometimes encounter this situation with unison. The good news is that\n> in 99,999% of cases where I'd encounter a problem, Unison shows a\n> conflict on the index file (modified on both sides). So, in these cases,\n> I just use Git normally to synchronize, decide that one side becomes the\n> reference, and rsync to the other to resolve the Unison conflict.\n>\n> Also, you have to ensure that you synchronize both file\n> additions/modifications, and file deletions. I often make the mistake of\n> using rsync without --delete, and it confuses the branch storage format\n> (I keep my local unpacked branch, and the packed branch is hidden by\n> it).\n\nAll correct but .git/index may need to be refreshed, as your\ncloudSync is unlikely to sync stat details across filesystems,\nespecially inum and possibly uid.\n"}]}