Giter Site home page Giter Site logo

git-remote-drive's Introduction

Git Remote Drive

We are not at a working version yet

Progress to initial working first draft:

  • capabilities
  • list and list for-push
  • option
  • fetch - include notes and tags
  • push

Things to go in a v1:

  • --init or --auth option to run outh2 flow
  • loopback interface redirect for oauth2 browser, instead of copy/paste
  • caching layer to reduce naive API calls
  • use go's channels to push or fetch multiple objects concurrently
  • continuous integration

What is it?

A git remote helper for storing git repositories in Google Drive using the Google Drive API.

$ git remote add drive drive://git/my-project.git
$ git push drive master
...
$ git pull drive/master

Requirements

  • go 1.10.1 or later

Getting Started

Setting up

  • Create a project in the Google API Console
  • Enable the Google Drive API in your project:
    • Go to the API Library page
    • Find Google Drive API and enable it for your project.
  • Create a client secret key:
    • Go to the Credentials page
    • From the Create credentials dropdown select OAuth client ID
    • Select Other as the application type
    • Name the client something like git-remote-drive-client
    • Click Create
    • Dismiss the popup with the client ID and secret
  • Download the credentials file and store it as ~/.git-remote-drive.secret
  • Change the permissions of the secret file to make them private

On a unix or unix-like system:

$ chmod 0600 ~/.git-remote-drive.secret

We assume you have a GOPATH set up and the go tool on your PATH. Instructions for this can be found at https://golang.org/doc/code.html

Download and install git-remote-drive:

$ go get github.com/cakemanny/git-remote-drive
$ go install github.com/cakemanny/git-remote-drive
  • Make sure $GOPATH/bin is on your path
  • Or link the binary into a folder that is, e.g:
$ ln -s $GOPATH/bin/git-remote-drive ~/bin/.

Run the outh2 flow to give the app access to your Google Drive account.

$ git-remote-drive --init

You will be prompted to a follow go to a URL in your browser. Go to the URL authorise the app and then paste the token back into the prompt.

A token file will be saved in your home directory: ~/.git-remote-drive.json

Create a test repository

Create a git repository with at least one commit

mkdir test-project && cd test-project
echo "This is a test project" > README.txt
git add README.txt
git commit -m "initial commit"

Then add the remote:

$ git remote add origin drive://path/to/repos/test-project.git

You should now be able to push and fetch from the remote:

$ git push origin master
$ git fetch origin

Workflow

TODO: write about cloning

Storage Details

TODO: write about which parts of existing project layout we use

Potential Problems

Google Drive allows multiple files or directories with the same path. Git objects are content addressable, so if duplicates are created this should not cause any problems - they will be identical and are never updated.

On the other hand, refs are updated and created. Concurrent pushes may cause duplicate refs to be created.

How does Git Remote Drive solve this problem?

Inspiration and Reason

This was inspired by having used https://github.com/anishathalye/git-remote-dropbox for a few years, and thinking it would be interesting to see if other cloud user file storage providers could be used. I also needed to learn go, so what better a marrying?

Since this is my first project in go, please feel free to comment on the implementation, and suggest improvements, perhaps by pull request.

The gitremote-helpers man page and the Git Internals chapter of the of the Pro Git book were the main references used for this implementation.

Copyright © 2018 Daniel Golding - MIT License

git-remote-drive's People

Contributors

cakemanny avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.