How to add a local git repo from colab to github
how to add locally hosted code (such as code in colab) to github
Some Basic Git Commands
-
git init
: initializes a brand new Git repository -
git add
: stages a change. -
git commit
: saves the snapshot to the project history and completes the change-tracking process. Anything that's been staged withgit add
will become a part of the snapshot withgit commit
. -
git status
shows the status of changes as untracked, modified, or staged. -
git branch
: shows the branches being worked on locally. -
git push
: updates the remote repository with any commits made locally to a branch.
For more details: About Git
What you'll need
- a Person Access Token
- a link to your newly created (empty) github repository
%%sh
### Step 1: Initialize a Git repository in your local folder
##########
# go to the 'test' folder
cd test
# initializes a Git repository in the test folder
git init
## Step 2: Set your account identity in this repository.
##########
git config user.email "intodeeplearning@gmail.com"
git config user.name "intodeeplearning"
## Step 3: Make the first commit
##########
# git isn't aware of the file READ.md , stage it
git add README.md
# commit the staged changes with a message
git commit -m "first commit"
# If you'd like, rename the default branch to 'main'
git branch -M main
## Step 4: Push your local git repository to github
##########
# provide the path for the repository you created on github with Personal Access Token
# by adding remote origin
git remote add origin https://ghp_9jvw82CCplyvDBTTTqMtmZ4wLDjuqj3LufGl@github.com/intodeeplearning/test.git
# Pushes the 'main'branch in your local repository
# up to the remote repository you specified as the origin
git push -u origin main