Skip to content

Instantly share code, notes, and snippets.

@howard-haowen
Created March 7, 2021 10:14
Show Gist options
  • Save howard-haowen/5de54a45e70e64c6975add2ee6d97db8 to your computer and use it in GitHub Desktop.
Save howard-haowen/5de54a45e70e64c6975add2ee6d97db8 to your computer and use it in GitHub Desktop.
Git commands for transferring data from GDrive to GitHub

Execute the following commands on Colab

Add a new repo on GitHub

Suppose it's named MY_REPO

Set the GitHub user email

!git config --global user.email '<USER_EMAIL>'

Set the GitHub user name

!git config --global user.name '<USER_NAME>'

Clone the repo from GitHub to Colab

!git clone https://<USER_NAME>:<ACCESS_TOKEN>@github.com/<USER_NAME>/<MY_REPO>

Copy all files from a directory in GDrive to Colab

!cp -R {SOURCE_DIR} /content/<MY_REPO>

Enter the directory for the local repo

%cd <MY_REPO>

Add all files

!git add --all

Check changes to be committed (optional)

!git status

Commit changes

!git commit -m ''

Push to GitHub

!git push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment