The Computer Oracle

Google Drive with a .gitignore like option

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 Google Drive With A .Gitignore Like Option
00:31 Accepted Answer Score 3
01:01 Answer 2 Score 3
01:28 Answer 3 Score 2
02:11 Answer 4 Score 2
05:09 Answer 5 Score 0
05:42 Thank you

--

Full question
https://superuser.com/questions/820145/g...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#googledrive #git #macos

#avk47



ACCEPTED ANSWER

Score 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.




ANSWER 2

Score 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.




ANSWER 3

Score 2


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.




ANSWER 4

Score 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.




ANSWER 5

Score 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.