Home > Enterprise >  How to use git with on google drive?
How to use git with on google drive?

Time:09-30

I've spent the last 15 hours troubleshooting git with no luck.

For the past 6 months I have been using google drive (G:/) as my local git repo. My github Personal Access Token expired, and after updating it (with unfortunately a lot of troubleshooting, reinstalling git, rstudio, and R), git no longer works with google drive. I think I messed up something with git on my computer while I was troubleshooting my github PAT...

I have deduced that my issue it's not related to github, R, or Rstudio, but something with git. While I am able to initialize new repos anywhere on C:/ using git init, I cannot init a blank repo anywhere in G:/ (I also cannot clone from github or from C:/). I have tried git init from within G:/My drive, git init "G:/My Drive" and git init G:/My\ Drive. All of these return the error: fatal: bad config line 3 in file G:/My Drive/np/.git/config(pic). I get the same error when I rerun git init and if I delete .git/config and run git init.

When I use git init in G:/, all the files in git./ (e.g., .git/config, .git/description, and.git/HEAD) are corrupted with random content from other files on my computer (often from csv files). I have also paused google sync to eliminate google backup as a culprit.

git config --global -l returns the following:

$ git config --global -l
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=D:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
core.fsmonitor=true
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master

I've read from several stackoverflow questions that you shouldn't git with google drive (or any cloud storage) as they treat each file separately rather than the repo as a whole (as git does). However, my entire workflow and file management is through drive, and most of my work is solo so I would prefer to keep all my work centralized in Drive.

CodePudding user response:

Share a Google Drive Hosted Git Project

STEP 1: share the Git repository folder with project collaborators from Google Drive.

Each collaborator should then: STEP 2: Download and install Google Drive for desktop and ensure that Git is installed on their system.

STEP 3: Sync the shared Git project folder to their local Google Drive.

STEP 4: Open a command-line interface in a new folder and execute the Git clone command to clone the shared project.

git clone PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

STEP 5: Configure a Git remote for the shared project.

git remote add REMOTE_NAME PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

STEP 6: Push/Pull project changes to/from the remote … changes will sync with Google Drive. Example:

git push gdrive master

CodePudding user response:

You should not store repositories on Google Drive or other cloud syncing services. Git writes files into the repository in a specific order with specified syncing so as to ensure the repository is in a consistent state, and cloud syncing service don't sync the data in the same way.

You may prefer to work with Google Drive, but it will almost certainly corrupt your repository eventually if you store a Git repository in it. If you don't prefer to have corrupt data, then you should avoid Google Drive for your repositories. The Git FAQ will be updated at some point to mention this explicitly, and I highly recommend that you take heed.

It is safe to store a bundle file (created with git bundle) or an archive of the repository (preferably tar, not zip) using a cloud syncing service if necessary. Note that if you include the working tree in your archive, you should not share the repository with other people, because it isn't safe to share a working tree across multiple users.

  • Related