Using git with google drive

Initialising repo on Google Drive:

  • clone the repository you wanted to use with google drive into your local work directory.

cd ~/work

git clone https://example.com/project-group/sample-repo.git

  • Download google file stream app from google(Streams files on demand instead of making entire drive offline)
  • Post installation, login with google email.
  • Let’s say Google Drive is mounted on /Volumes/GoogleDrive folder on your machine.
  • Create repo under /Volumes/GoogleDrive/Shared\ drives/Project\ Drive/work/ using the below command

git init — bare sample-repo

  • In your local work directory, set git remote to google drive’s sample-repo folder and push all the branches, tags etc.

cd ~/work/sample-repo

git remote add origin file:///Volumes/GoogleDrive/Shared\ drives/Project\ Drive/work/sample-repo

git push origin — all

git push origin — tags

Sharing initialised repo with everyone else:

  • Download google file stream app from google(Streams files on demand instead of making entire drive offline)
  • Post installation, login with google email.
  • Let’s say Google Drive is mounted on /Volumes/GoogleDrive folder on your machine.
  • If you have sample-repo repo under ~/work already

cd ~/work/sample-repo

git remote add origin file:///Volumes/GoogleDrive/Shared\ drives/Project\ Drive/work/sample-repo

git pull -r origin master

Some common problems using git with google drive:

  • Coordination is required when multiple people would like to push to master at the same time. Sometimes when one person pushes to master and due to some network problem, if drive is not able to replicate your local commit to everyone else. There would problems as google drive has its own way of resolving conflicts when it comes online.

Eg: If A is pushing to master. Publish the last known commit id to everyone in the group. If B wants to push another commit to master, B can check if the last known commit id mentioned by A is available locally before pushing.

Same rules apply to any branch where multiple people are working at the same time.

Go, Rust, Erlang, Java at work || Blogging, Open source tools, Embedded systems, Industrial robotics as hobby