git - 在 Colab 中将文件推送到 Git 时出错 : fatal: could not read Username for 'https://github.com' : No such device or address

标签 git google-colaboratory

我正在尝试学习github。

我在 github 上创建了一个私有(private)存储库 Repo。

我在 Google Drive 中创建了一个文件夹,Folder,其中包含一些文件。

我在 Google Colab 上运行以下代码:

%cd /content/drive/My Drive/Folder
!git init
!git config --global user.email "JohnSmith@outlook.com"
!git config --global user.name "JohnSmith"
!git add -A 
!git commit -m "first commit"

然后我尝试了:
!git remote add origin https://<johnsmith>:<password>github@github.com/<johnsmith>/Repo.git

我从中得到:
/bin/bash: johnsmith: No such file or directory

然后我尝试了:
!git remote add origin https://github.com/johnsmith/Repo.git
!git push -u origin master

我从中得到:
fatal: could not read Username for 'https://github.com': No such device or address

请注意,出于隐私目的,我更改了 Repo 的名称和用户名。

所以我的目标是将文件夹放在 github 的 Google 驱动器上。我该怎么做?

最佳答案

2020 |混帐 v2.17.1
解决方案:
致命:无法读取“https://github.com”的用户名:没有这样的设备或地址
只需执行以下步骤
1.为github生成personal-access-TOKEN:来自https://github.com/settings/tokens

  • 要推送更改,直到您提到的提交,然后运行以下命令。

    git push https://<YOUR-PERSONAL-ACCESS-TOKEN>@github.com/<User-Name>/<Repo-Name>.git



  • 例子
    添加一些文件或进行一些更改
    !git config --global user.email "JohnSmith@outlook.com"
    !git config --global user.name "JohnSmith"
    !git add . 
    !git commit -m "first commit"
    !git push https://123dpope888040e2s90136d8bxx99927@github.com/JohnSmith/hello.git
    

    关于git - 在 Colab 中将文件推送到 Git 时出错 : fatal: could not read Username for 'https://github.com' : No such device or address,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61424599/

    相关文章:

    具有 merge 子项的 Git rebase 分支

    java - eclipse中删除的文件,如何恢复

    来自云托管 jupyter 的 pandas.read_clipboard?

    python - Google colab TPU 并在训练时从光盘读取

    git - 如何在 bash 上使用 git interactive 获得彩色补丁?

    git - 如何在 Mac OS 中设置 kdiff3?

    android - 何时将分支 merge 到主分支

    python - 无法加载在 Google Colaboratory 中创建的模型

    matplotlib - 如何在 Google Colab 中使用 matplotlib 绘制交互式可绘制图像?

    linux - 无法将 C++ 扩展上传到 Colab