Google Drive application and symbolic links

The Google Drive application can be used to sync files stored on your Google Drive with your local file system. When installing the Mac application a folder named “Google Drive” is created and automatically synchronised with your Google Drive in the cloud.

Most likely you do not want to store all data you want to synchronise with your Google Drive within that exact folder in your local file system. Furthermore, you do not want to start storing different file versions in two different locations on your local file system, one in your Google Drive folder and one at the “proper” location according to your file system layout. The first idea when using Unix/Linux file systems would be to store your data where you actually want it to be and create a symbolic link within the Google Drive folder. That way you can work in your file system structure and still have the same version synchronised with your Google Drive. For this you would use the following command:

~> ln -s ~/foo/bar/file ~/Google\ Drive/foo/bar/file

Unfortunately, the Google Drive application is implemented such that it ignores symbolic links. So your data will never be synchronised with your Google Drive using this approach.

Nevertheless, it works the other way around. So if you want to store a file on your Google Drive you should just change your point of view a little bit. In general this means you do not want to store a local file into your Google Drive, you want to store and use a file on your Google Drive locally.

First of all, create the file or folder you want to store on your Google Drive within your Google Drive folder. On my Mac it is located at ~/Google\ Drive. Secondly, just create a symbolic link in you local file system at the appropriate location which references the file/folder within the Google Drive folder:

~> ln -s ~/Google\ Drive/foo/bar/file ~/foo/bar/file

Now changes can be made to the file ~/foo/bar/file and they are directly synchronised with the file stored on your Google Drive.

Leave a Reply