user42493
user42493

Reputation: 1113

error when pushing files to Git in Colab: fatal: could not read Username for 'https://github.com': No such device or address

I was trying to learn github.

I have created a private repository, Repo, on github.

I have created a folder, Folder, with some files in it in Google Drive.

I run the following codes on Google Colab:

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

then I tried:

!git remote add origin https://<johnsmith>:<password>[email protected]/<johnsmith>/Repo.git

from which I got:

/bin/bash: johnsmith: No such file or directory

then I tried:

!git remote add origin https://github.com/johnsmith/Repo.git
!git push -u origin master

from which I got:

fatal: could not read Username for 'https://github.com': No such device or address

Note that I change the name of the Repo and usernames for privacy purpose.

So my goal is to put the folder on Google drive in github. How do I do it?

Upvotes: 4

Views: 4217

Answers (1)

Deepak Sahu
Deepak Sahu

Reputation: 81

2020 | git v2.17.1

SOLUTION FOR :

fatal: could not read Username for 'https://github.com': No such device or address

Just do the following step

1. Generate personal-access-TOKEN for github: from https://github.com/settings/tokens

  1. To push changes do thing till commit as you mentioned then run the following command.

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


example

add some files or make some changes

!git config --global user.email "[email protected]"
!git config --global user.name "JohnSmith"
!git add . 
!git commit -m "first commit"
!git push https://[email protected]/JohnSmith/hello.git

Upvotes: 8

Related Questions