Can I push/pull directly from my google drive online?

后端 未结 7 2189
滥情空心
滥情空心 2020-12-03 06:27

There are methods to sync my local git repository over to my google drive via google drive sync windows application, but I was wondering whether I could bypass its need alto

7条回答
  •  囚心锁ツ
    2020-12-03 07:05

    If you are running a Unix shell and have Google Drive locally installed on your machine, you can add a script to your .bash_profile or .zshrc file like this...

    # Initialize a remote repo on "local" Google Drive and push to it for safekeeping.
    function mkr() {
      CWD=$(PWD)
      REPONAME=${PWD##*/}
      REPOPATH=/Users/Bob/Google\ Drive/Repos/$REPONAME
      mkdir -p $REPOPATH
      cd $REPOPATH
      git init --bare
      cd $CWD
      git remote add origin $REPOPATH
      git push origin master
    }
    

    Assuming you have already run git init, you can type mkr from the command line inside your local project directory. After this mkr step, you can run git push like normal as if it lives on GitHub, Bitbucket, etc. You just won't have the usual niceties from the remote side.

提交回复
热议问题