how to push code to an existing repo github code example

Example 1: git push existing code to new repository

git remote add origin <remote repository URL>

Example 2: git existing code to new repository

cd myapp
git init
git remote add origin https://github.com/myname/myapp.git
git add .
git commit -m "Initial commit"
git push -u origin master

Example 3: pushing an existing rep from command line to github repo

git remote add origin https://github.com/Mo-Aziz/React-shopping-cart.git
git branch -M main
git push -u origin main

Example 4: push a project to an existing repoin github using git

$ git init -b main

Tags:

Misc Example