how to push a local repo to github code example

Example 1: push code to github command line

git add .
git commit -m "message for the commit"
git remote add origin https://url-of-github-repo
git push origin master

Example 2: upload new repo to git

echo "# Can-I-Shop-2" >> README.md
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/username/projectname.git
git push -u origin master

Example 3: git add existing project to repository

git remote add origin <repository url>
git branch -M main
git push -u origin main

Example 4: initialize a repo and push to github

git init
git add -A
git commit -m 'Added my project'
git remote add origin [email protected]:sammy/my-new-project.git
git push -u -f origin master

Example 5: pushing to github

git add .
git commit -m "First commit"
git push origin master

Example 6: how to push repository to github

$ git init -b main