Tech Streams thoughts.toString();

Google Drive as a Simple Git Host

Github, Bitbucket, GitLab, Google Cloud Source Repositories and others are fantastic Git hosting services. But for personal projects and small team collaboration Google Drive can also provide a simple solution.



Overview


I’ve taken a several month writing hiatus during which I was able to develop some helpful Google Apps Scripts which I hope to share in the future. But in this and upcoming posts I want to focus on some personal workflows and tools I use to help me be more productive during script develop.

One such tool … Google Drive … can act as a simple Git host for backup and sharing of personal and collaborative small team script projects.

Let’s see how easy this is to set up.



Setup Google Drive for Git Hosting


STEP 1: Download and Install Google Drive for your desktop and ensure Git is installed on your system


STEP 2: Create a Git respository for your project


STEP 3: From inside the project folder, create a ‘bare’ Git clone of the repository on Google Drive using the following command

git clone --bare . PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

Example: git clone --bare . ~/GoogleDrive/Git/addon.git


STEP 4: Configure a Git remote with the following command

git remote add REMOTE_NAME PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

Example: git remote add gdrive ~/GoogleDrive/Git/addon.git


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

Example: git push gdrive master

or

Example: git pull gdrive master



Share a Google Drive Hosted Git Project


To share a Google Drive hosted Git project with collaborators:


STEP 1: Share the Git repository folder with the collaborator(s) on 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: Execute the Git clone command for the shared project

git clone PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

Example: git clone ~/GoogleDrive/Git/addon.git


STEP 5: Configure a Git remote for the shared project with the following command

git remote add REMOTE_NAME PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git

Example: git remote add gdrive ~/GoogleDrive/Git/addon.git


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

Example: git push gdrive master

or

Example: git pull gdrive master


BEST PRACTICE - If sharing the Git repository, collaborators should coordinate ‘push’ and ‘pull’ operations so as not to have sync conflicts which could leave the Git repository in an unstable state.


Dropbox is another alternative for simple Git hosting.

Posted with : google-drive, development