DEV Community

kk1123
kk1123

Posted on

how to push a local code repository to a remote repository

1. init your local local repository

cd /path/to/your/project      # Go to your project directory
git init                      # Initialize a Git repository
git add .                     # Add all files
git commit -m "Initial commit"  # Commit the changes
Enter fullscreen mode Exit fullscreen mode

2. Push the local repository to the remote

git remote add origin https://github.com/kkju1123/courseSummary.git
git branch -M main            # Rename to 'main' (optional but standard)
git push -u origin main       # Push to GitHub
Enter fullscreen mode Exit fullscreen mode

3. what does -u mean

-u is short for --set-upstream
From now on, link the local main branch to the origin/main branch on GitHub, so you don’t need to specify them every time.

Top comments (0)