Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to push from colab to github

I cloned a public github repo of mine into my drive. I am able to use colab with the notebooks. I can also pull. I however face the following error when trying to push despite having correctly configurated:

!git config --global user.email "my_email"
!git config --global user.name "my_user"

When doing !git push origin master I get the following error:

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

Has somebody encountered this problem before?

like image 538
G. Macia Avatar asked Dec 23 '19 11:12

G. Macia


2 Answers

Here is how to clone, add a file, and push back

uname = "korakot"
!git config --global user.email '[email protected]'
!git config --global user.name '$uname'

from getpass import getpass
password = getpass('Password:')
!git clone https://$uname:[email protected]/korakot/myrepo
%cd myrepo
# create a file, then add it to stage
!git add hello.txt
!git commit -m 'commit message'  # commit in Colab
!git push origin master          # push to github
like image 62
korakot Avatar answered Oct 05 '22 22:10

korakot


None of the options mentioned above worked for me. I finally found the answer in this Medium article. Basically, the key line that I was missing was:

> !git remote add origin https://<USERNAME>:<PASSWORD>@github.com/<USERNAME>/reponame.git
like image 24
G. Macia Avatar answered Oct 06 '22 00:10

G. Macia