Add an Existing Project to GitHub



Resource


  1. Create a new repository for your project on GitHub.

  2. Open Git Bash from your local folder.

  3. Initialize the local directory as a Git repository.

git init -b main 
  1. Add the files in your new Git repository. This will stage all the files in your project ready for the first commit.
git add .
  1. Commit the added files.
git commit -m "First commit"
  1. From GitHub, copy the remote repository URL.

  2. Add the URL you just copied for the remote repository. This iswhere your local files will be pushed to.

# Set Remote Repository # Add your URL in place of <REMOTE_URL>
git remote add origin  <REMOTE_URL> 
  1. Verify remote
git remote -v
  1. Push your project to GitHub
git push origin main

Problem Shooting

If you encounter problems with this you may want to try $ git pull --rebase before attempting to push again.