18

With git and hg, etc, you can define .gitignore file that will prevent certain folders/filetypes from being saved to the repo.

Is there anything of that nature for Google Drive? In the preferences, I see I can select a parent folder to not be synced, but I see nothing along the lines of subfolders.

Env is OS X...

1

5 Answers 5

3

The way I deal with this is to:

  1. Disable starting GoogleDrive on system startup
  2. Create a bash script to clear temporary and log files first, and then run google drive
  3. Schedule that script to start on system boot

I know its far from perfect, but its something.

4
  • 1
    I like it. It's not so far from perfect. Commented Dec 6, 2014 at 23:10
  • Unfortunately, it's one of the better solutions I've seen since Google has yet to implement a feature that allows us to exclude particular filetypes, etc. My copy of Adobe InDesign will only allow me to save a file once because the .idlk file (lock file) becomes perpetually stuck trying to upload in Google Drive sync. Commented Oct 1, 2015 at 13:51
  • 3
    Not quite a solution. For developers, those "unwanting to sync" files are actually required for development. Like node_modules, .git files, and many others
    – scazzy
    Commented Feb 8, 2017 at 7:19
  • @EltonJain But still, IDEs like PHPStorm generate thousands of little files for each new project which, or even cache those settings ... all of this nonesense belongs in the local
    – samayo
    Commented Feb 24, 2017 at 13:35
3

Symbolic links could be used in this case. Google Drive doesn't seem to detect symbolic links, so you can put your node_modules somewhere outside the Drive, then inside the drive create a symbolic link to node_modules.

Example structure:

google_drive
    my_app
        package.json      file
        app.js            file
        my_apps_stuff     folder
        node_modules      symbolic link ==> /home/me/gdrive_ignored/my_app/node_modules

Linux, Windows, and OSX all have symbolic links.

If you run into issues with your application not working with symbolic links, then create a hard link.

3
  • This seems like a better solution. What about when you deploy that file, you have to do npm install again right?
    – samayo
    Commented Jul 9, 2019 at 17:56
  • Yes. The modules should not be bundled with the software when deploying.
    – Jack Cole
    Commented Jul 9, 2019 at 18:57
  • Thank you! That gave me a great idea to avoid syncing my .git folder!
    – lvil
    Commented 8 hours ago
3

For Windows, I use a simple Powershell script that relocates the desired folders (node_modules) to a different location outside Google Drive, and replaces them with Symbolic links so everything keeps working.

It can be found in this repo, along with the instructions to set it up.

2

This problem bothers me for years and I recently found a better way to deal with it.

The main idea is to use ".gitignore like" option to backup the files.

So just use .gitignore directly by the powerful version control tool: git

My OS is Windows 10. I perform the following commands under Windows Subsystem for Linux.

Assume that there are many repositories under local/codes. Each of them has remote connected to Github etc. or not.

Like the following structure:

local/
└── codes/
    ├── repo_1/
    │   ├── .git/
    │   ├── .gitignore
    │   └── .../
    ⋮
    └── repo_i/
        ├── .git/
        ├── .gitignore
        └── .../

Despite using Github to remote backup is convenient, the goal is to backup in Google Drive.

  • Step 1: setup local in local
    git init
    cd codes
    git submodule add <path_to_repo_1>
    ⋮
    git submodule add <path_to_repo_i>
    cd ..
    git add -A
    git commit -m "first commit"
    

And we make another directory backup which is the backuping folder for Google Drive.

  • Step 2: setup backup in backup
    git init
    git remote add origin <path_to_local>
    git pull origin master
    git submodule update --init --recursive
    

For more details about submodule update, you can refer to this link.

The magic here is that we set the remote <path_to_local> in backup so that it will be a "remote" repository for backup. After that, all git pull will follow all .gitignore recursively under all directories!

So now the backup folder is like:

backup/
├── .git/
├── .gitmodules
└── codes/
    ├── repo_1/
    │   ├── .git
    │   ├── .gitignore
    │   └── .../
    ⋮
    └── repo_i/
        ├── .git
        ├── .gitignore
        └── .../

without any files specified in .gitignore. Just like a local Github!

  • Step 3: Setting Google Backup and Sync on the folder: "backup/codes"

  • Step 4: Keep updating files...

    • in local
      git submodule update --recursive --remote
      git add -A
      git commit -m "commit message"
      
    • in backup
      git pull origin master
      git submodule update --recursive
      

Some concerns:

  1. Duplicate files?

    Yes! It's a feature not a bug.

    Since for each Github repository, the maximum storage size is 100 MB. So the total disk usage should not be large after filtered by .gitignore.

    To backup is to copy files on different devices. By making backup folder in another hard drive, we can now backup files to different hardware, to Google drive and to Github simultaneously!!


This idea ​comes from learning more features in git.

I watch the Missing Semester Version Control (Git).

Anish introduces very clearly and I learn a lot about git. In the part that he creates local git remote makes me come up with this idea.

1
  • Please stop editing your answer as it bumps to the front page every time.
    – DavidPostill
    Commented Jun 27, 2021 at 13:47
0

It might be third-party solution, but it works for me.

If you are a developer and are familliar with git and any cloud git repository (Github, gitlab, etc), move your project outside of google drive and push it to your private repo (create it if needed).

If your project already has origin set up, you can either add additional remote for your git repo, or fork the project and make origin to point to your private repo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .