how to initialize existing git repository to local code example
Example 1: git add existing project to repository
git remote add origin <repository url>
git branch -M main
git push -u origin main
Example 2: initialize a repo and push to github
git init
git add -A
git commit -m 'Added my project'
git remote add origin git@github.com:sammy/my-new-project.git
git push -u -f origin master