threads / discuss / 22214

Syncing a git working tree with Dropbox?

Subject: Syncing a git working tree with Dropbox?

## tl;dr

4 messages between Jan 13, 2010 and Jan 14, 2010.

replies: 3people: 3as markdown or json

chombee· Jan 13, 2010, 23:57 UTC · lore

I've heard of people keeping a bare repo in their Dropbox folder (https://www.dropbox.com/) and pushing to and pulling from it, letting Dropbox sync the bare repo between their machines. In other words using Dropbox as a form of hosting for a private git repo. What I want to do is sort of the other way around.

I keep on getting into the following mess: I have some changes in my working tree on machine A, I stop working on machine A and don't commit and push the changes (to my remote, 'central' bare repo) either because they're not ready yet, or I forget to commit or push. Later on I arrive at machine B which has its own clone of the same repo, but because I didn't commit and push the changes on machine A I don't have access to them on machine B and I can't continue working on them. The two machines are physically located far away from each other and they're not accessible over the internet. Argh!

Dropbox is a proprietary sync service that gets around this problem because it automatically syncs your files whenever you save them. But I still want to keep my project in a git repo. I'm assuming that keeping the actual .git folder in a Dropbox folder, so that when git makes changes inside the .git folder Drobox syncs them, would be a bad idea. It seems like taking two different synchronisation systems and mashing them into each other. But what about just the working tree?

My idea is that I keep my .git folder safely outside of my Dropbox folder, but my git repository has a detached working tree that is located in the Dropbox folder. On machine B it would be the same setup. So the two machines each have their own clone of the git repo and these are synchronised by git push and git pull with a 'central' remote repo. But the two clones share the same working tree, or more accurately their working trees are synced by Dropbox.

The working tree is just files, I don't see how it's different from Dropbox syncing any other files. Dropbox and git ought not to collide in any way. So this should work fine shouldn't it?

This way I don't need to commit and push my changes until they're ready/I remember to, but whenever I move from machine A to machine B my uncommitted changes will still be available to me because Dropbox has synced my working tree automatically.

Tay Ray Chuan· Jan 14, 2010, 05:39 UTC · re: chombee · lore

Re: Syncing a git working tree with Dropbox?

Hi,
On Thu, Jan 14, 2010 at 7:57 AM, chombee <chombee@lavabit.com> wrote:
Show 11 quoted lines
> My idea is that I keep my .git folder safely outside of my Dropbox
> folder, but my git repository has a detached working tree that is
> located in the Dropbox folder. On machine B it would be the same setup.
> So the two machines each have their own clone of the git repo and these
> are synchronised by git push and git pull with a 'central' remote repo.
> But the two clones share the same working tree, or more accurately their
> working trees are synced by Dropbox.
>
> The working tree is just files, I don't see how it's different from
> Dropbox syncing any other files. Dropbox and git ought not to collide in
> any way. So this should work fine shouldn't it?
Your changes in git (like new commits) won't be synced.
-- 
Cheers,
Ray Chuan
Geoffrey Lee· Jan 14, 2010, 13:19 UTC · re: Tay Ray Chuan · lore

Re: Syncing a git working tree with Dropbox?

On Wed, Jan 13, 2010 at 9:39 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:
Show 14 quoted lines
> On Thu, Jan 14, 2010 at 7:57 AM, chombee <chombee@lavabit.com> wrote:
>> My idea is that I keep my .git folder safely outside of my Dropbox
>> folder, but my git repository has a detached working tree that is
>> located in the Dropbox folder. On machine B it would be the same setup.
>> So the two machines each have their own clone of the git repo and these
>> are synchronised by git push and git pull with a 'central' remote repo.
>> But the two clones share the same working tree, or more accurately their
>> working trees are synced by Dropbox.
>>
>> The working tree is just files, I don't see how it's different from
>> Dropbox syncing any other files. Dropbox and git ought not to collide in
>> any way. So this should work fine shouldn't it?
>
> Your changes in git (like new commits) won't be synced.

You have to sync your .git directory. For example, using your setup, if you switch branches on Machine A, your working directory will change on Machine B, but Machine B will still think it's on the previous branch. This scenario would cause a lot of problems for Git.

There shouldn't be any problems with placing your entire repository (working tree and .git directory) inside Dropbox as long as you only use one computer at a time.

-Geoffrey Lee
chombee· Jan 14, 2010, 13:40 UTC · re: Geoffrey Lee · lore

Re: Syncing a git working tree with Dropbox?

Ok, I was aware that I would have to sync the .git directories also, but my plan was to do that in the normal way (git pull and git push) but sync the working tree automatically with Dropbox. However, I'm now imagining all kinds of mind-bending problems this might cause. If I commit and push some changes on machine A, and Dropbox syncs the working copy, then I go to machine B, git status will show that machine B has changes to commit, until I do git pull on machine B. As Geoffrey points out, changing branches could be even worse!

In any case, I've had problems with detached working trees. With an older version of git it was refusing to checkout a detached working tree. I upgraded git and checkout worked, but it refused to do git pull.

Ah well.

I'm not too sure about keeping the .git directory itself in Dropbox. Googling it, it seems lots of people do it without any problems, but there are some reports of it going haywire.

On Thu, Jan 14, 2010 at 01:39:10PM +0800, Tay Ray Chuan wrote:
Show 24 quoted lines
> Hi,
> 
> On Thu, Jan 14, 2010 at 7:57 AM, chombee <chombee@lavabit.com> wrote:
> > My idea is that I keep my .git folder safely outside of my Dropbox
> > folder, but my git repository has a detached working tree that is
> > located in the Dropbox folder. On machine B it would be the same setup.
> > So the two machines each have their own clone of the git repo and these
> > are synchronised by git push and git pull with a 'central' remote repo.
> > But the two clones share the same working tree, or more accurately their
> > working trees are synced by Dropbox.
> >
> > The working tree is just files, I don't see how it's different from
> > Dropbox syncing any other files. Dropbox and git ought not to collide in
> > any way. So this should work fine shouldn't it?
> 
> Your changes in git (like new commits) won't be synced.
> 
> -- 
> Cheers,
> Ray Chuan
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
On Thu, Jan 14, 2010 at 05:19:08AM -0800, Geoffrey Lee wrote:
Show 30 quoted lines
> On Wed, Jan 13, 2010 at 9:39 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:
> > On Thu, Jan 14, 2010 at 7:57 AM, chombee <chombee@lavabit.com> wrote:
> >> My idea is that I keep my .git folder safely outside of my Dropbox
> >> folder, but my git repository has a detached working tree that is
> >> located in the Dropbox folder. On machine B it would be the same setup.
> >> So the two machines each have their own clone of the git repo and these
> >> are synchronised by git push and git pull with a 'central' remote repo.
> >> But the two clones share the same working tree, or more accurately their
> >> working trees are synced by Dropbox.
> >>
> >> The working tree is just files, I don't see how it's different from
> >> Dropbox syncing any other files. Dropbox and git ought not to collide in
> >> any way. So this should work fine shouldn't it?
> >
> > Your changes in git (like new commits) won't be synced.
> 
> You have to sync your .git directory. For example, using your setup,
> if you switch branches on Machine A, your working directory will
> change on Machine B, but Machine B will still think it's on the
> previous branch. This scenario would cause a lot of problems for Git.
> 
> There shouldn't be any problems with placing your entire repository
> (working tree and .git directory) inside Dropbox as long as you only
> use one computer at a time.
> 
> -Geoffrey Lee
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

← back to recent threads