Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 我可以直接从google drive在线推/拉吗?_Git_Google Drive Api - Fatal编程技术网

Git 我可以直接从google drive在线推/拉吗?

Git 我可以直接从google drive在线推/拉吗?,git,google-drive-api,Git,Google Drive Api,有很多方法可以通过GoogleDrive同步windows应用程序将我的本地git存储库同步到我的GoogleDrive,但我想知道是否可以完全绕过它的需要 从……到 $ git remote add origin https://drive.google.com/<my_folder>/<my_repository>.git $ git push github master $git远程添加源https://drive.google.com//.git $git推送g

有很多方法可以通过GoogleDrive同步windows应用程序将我的本地git存储库同步到我的GoogleDrive,但我想知道是否可以完全绕过它的需要

从……到

$ git remote add origin https://drive.google.com/<my_folder>/<my_repository>.git
$ git push github master
$git远程添加源https://drive.google.com//.git
$git推送github主机

不,你不能。Google drive上没有运行git

我还建议反对基于Google drive/Dropbox的解决方案,转而选择git托管解决方案。例如,它提供了一些免费的私有存储库。您可以找到一些关于不同git托管站点的比较信息

正如人们所指出的(OP已经知道),您可以将裸存储库放在本地的Google Drive/Dropbox文件夹中,然后使用它,但是,有一些警告。云服务有自己的用于合并冲突的系统,这在git中并不起作用。考虑情景:

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

  • 然后忘记它,在线使用设备B,将提交推送到GoogleDrive文件夹,这些更改会同步

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

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

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

关于此主题(,相关部分在此复制):

假设您有一个名为
johndoe
的项目,其中包含一个文件
README
,如下所示:

/var/www/html/johndoe/
/var/www/html/johndoe/README
在此处初始化空Git存储库:

$cd/var/www/html/johndoe
$git init
$git添加自述文件
$git commit README-m“初始提交”
将Google Drive所在的目录更改为,并初始化裸存储库:

$cd/Users/myusername/Google\Drive/
$mkdir johndoe
$cd johndoe
$git init—裸
返回您的工作目录:

$cd/var/www/html/johndoe
$git远程添加源file:///Users/myusername/Google\驱动器/约翰多
$git推送原始主机
要从Google Drive克隆Git存储库,请执行以下操作:

$cd/var/www/html/johndoe2
$git克隆file:///Users/myusername/Google\驱动器/约翰多

如果您运行的是Unix shell,并且在您的计算机上本地安装了Google Drive,您可以向.bash_配置文件或.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等上一样。您将无法从远程端获得通常的细节。

您可以像任何其他备份一样,在Google Drive上根据自己的需要归档您的工作文件夹,为了保持一致性,您可以使用crontab或一个简单的脚本来自动执行此操作,然后通过最适合您的Google Drive cli工具进行上传

爱德华多·罗萨斯(Eduardo Rosas)对如何使用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
你可以为此目的使用

  • 将文件直接上传到谷歌硬盘
  • 开放谷歌合作
  • 导入文件
  • 安装git(如Jupyter笔记本或Linux PC)

您已经完成了

有可能,检查其他答案,接受的答案应该更改。@AmrLotfy这不可能是OP想要的方式。他并不是在问谷歌硬盘文件夹中有无回购协议。@user1615903
我还建议反对基于谷歌硬盘/Dropbox的解决方案
为什么?我正在考虑使用硬盘作为我的主机,以便它在后台同步。Google Drive不提供自定义域服务,但我认为gweb.io提供。如果我错了,请纠正我。Dropbox与git配合很好:我喜欢创建这样一个工具。。。。需要更多关于GIT服务器的资料。链接文章是404'ing。@Michael存档@refi64怎么回事?我没有看到任何特定于Windows的内容。如果有任何关于Windows问题的报告(意味着它在Linux上工作)。我认为您不需要
文件:
限定符-所以可能这就是上面提到的Windows问题?文章链接未打开@Haralan DobrevOP希望使用git接口访问google drive,你的建议与他的需要无关。过去式适用。这取决于用户发布一个查询以支持,直到令人满意的Google Drive集成开始。