Skip to content
🚀 Steps to Add a Local Repository to GitHub Using Git
- Authenticate to GitHub on the command line
- Create a new repository on GitHub
- Copy the remote repository URL
- On the repository’s Quick Setup page, click the copy icon next to the URL to copy it to your clipboard.
- (You’ll use this URL in the next command.)
- Open Git Bash
- Navigate to your local project directory
- Use the
cd command to switch to the folder containing your local repository.cd path/to/your/project
- Add the remote repository URL
- Run the following command to link your local repo to the remote GitHub repo:
git remote add origin REMOTE-URL
- Replace
REMOTE-URL with the actual GitHub repository URL you copied earlier.
- More info: Managing remote repositories
- Verify the remote connection
- Confirm that the remote URL is set correctly by running:
git remote -v
- Push your local repository to GitHub
- Upload your local files to the GitHub repository using:
git push origin main
- If your default branch is named something other than
main (e.g., master or dev), replace main with your branch name.
- Learn more: About branches