Add an Existing Project to GitHub
-
Create a new repository for your project on GitHub.
-
Open Git Bash from your local folder.
-
Initialize the local directory as a Git repository.
git init -b main
- Add the files in your new Git repository. This will stage all the files in your project ready for the first commit.
git add .
- Commit the added files.
git commit -m "First commit"
-
From GitHub, copy the remote repository URL.
-
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>
- Verify remote
git remote -v
- 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.