代码之家  ›  专栏  ›  技术社区  ›  laggingreflex

我可以直接从我的谷歌硬盘在线推/拉吗?

  •  52
  • laggingreflex  · 技术社区  · 13 年前

    有一些方法可以通过谷歌驱动器同步窗口应用程序将我的本地git存储库同步到我的谷歌驱动器,但我想知道我是否可以完全绕过它的需要。

    Fro例如。

    $ git remote add origin https://drive.google.com/<my_folder>/<my_repository>.git
    $ git push github master
    
    6 回复  |  直到 13 年前
        1
  •  53
  •   1615903    10 年前

    不,你不能。谷歌硬盘上没有运行git。

    我还建议不要使用基于谷歌驱动器/Dropbox的解决方案,而是使用git托管解决方案。例如 Bitbucket 它提供了一些免费的私人存储库。你可以找到一些关于不同git托管网站的比较信息 here .

    正如人们所指出的(正如OP已经知道的那样),你可以将裸露的存储库放在你当地的Google Drive/Dropbox文件夹中,并使用它,然而,有一些注意事项。云服务有自己的系统来合并冲突,而这在git中并不起作用。考虑以下情况:

    • 您脱机使用设备A,将一些提交推送到Google Drive文件夹中的裸存储库,但由于您处于脱机状态,这些更改不会同步到云。

    • 然后你就忘记了,在线使用设备B,将提交推送到谷歌硬盘文件夹,这些更改就会同步。

    • 设备A已联机-您现在在Google Drive中发生冲突。

    当然,这是可以恢复的,但不方便。因此,我建议使用一种专门为git托管设计的解决方案。

        2
  •  24
  •   Harry Dobrev Sridhar R    6 年前

    Here is a very good article 关于这个问题( archived version here ,相关部分在此复制):

    假设您有一个名为 johndoe 使用文件 README 如下所示:

    /var/www/html/johndoe/
    /var/www/html/johndoe/README
    

    在此处初始化一个空的Git存储库:

    $ cd /var/www/html/johndoe
    $ git init
    $ git add README
    $ git commit README -m "Initial commit."
    

    将目录更改为Google Drive所在的位置,并初始化一个裸露的存储库:

    $ cd /Users/myusername/Google\ Drive/
    $ mkdir johndoe
    $ cd johndoe
    $ git init --bare
    

    返回到您的工作目录:

    $ cd /var/www/html/johndoe
    $ git remote add origin file:///Users/myusername/Google\ Drive/johndoe
    $ git push origin master
    

    要从Google Drive克隆您的Git存储库,请执行以下操作:

    $ cd /var/www/html/johndoe2
    $ git clone file:///Users/myusername/Google\ Drive/johndoe
    
        3
  •  6
  •   rwreed    6 年前

    爱德华多·罗萨斯有一个 article 关于如何使用colab做到这一点(只需要一个浏览器)。 基本上,您使用以下方式访问您的谷歌硬盘:

    from google.colab import drive
    drive.mount('/content/gdrive')
    #cd to the google drive you using the magic command
    %cd /content/gdrive/'My Drive'/[your drive folder for repo]
    #check your directory location with
    !pwd
    #clone your repo - Note this exposes your password so don't make the notebook public
    !git clone https://LaloCo:password%23@github.com/LaloCo/handson-ml.git
    #I find using a github personal access token easier
    !git clone https://user:PAT@github.com/repo
    
        4
  •  3
  •   A.R.    12 年前

    你可以使用 itDuzzit ,它们提供Google Drive和GitHub之间的直接云对云同步。他们有一个相当有限的 free tier 以及一些付费的。只要你的代码是开源的和/或你不介意第三方处理它,这可能是一个可行的解决方案。

        5
  •  1
  •   bholben    11 年前

    如果你运行的是Unix shell,并且在你的机器上本地安装了Google Drive,你可以像这样在.bash_profile或.zshrc文件中添加一个脚本。。。

    # 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
    }
    

    假设你已经跑了 git init ,您可以键入 mkr 从本地项目目录中的命令行。在此之后 mkr公司 台阶,你可以跑 git push 就像正常一样,就像它生活在GitHub、Bitbucket等上一样。你只是不会从远程获得通常的细节。

        6
  •  0
  •   Sabito Greg    5 年前

    您可以使用 google collab 为此目的。

    • 将您的文件直接上传到您的谷歌驱动器中
    • 打开谷歌拼贴画
    • 导入文件
    • 安装git(作为Jupyter笔记本电脑或Linux PC)

    你就完了

    推荐文章