Check Remote Repositories
git remote -v
Add, Change, or Remove a Remote
git remote add origin URL
git remote set-url origin URL
git remote remove origin
fetch vs pull vs push
git fetch origin # Download remote changes (no merge)
git pull origin main # fetch + merge
git push # Push local commits to remote
git push -u origin main # Push and set upstream branch
Common Pitfalls
- Never use
git push --forceon a shared repository - The
-uflag sets the upstream so futuregit pushworks without arguments
If you’re using SSH for GitHub authentication, set the remote URL to the SSH format. See Generate an SSH Key and Add It to GitHub.
Related Posts
- How to Push Your First Repository to GitHub
- How to Resolve Merge Conflicts After git pull
- Generate an SSH Key and Add It to GitHub
- Git Branch Basics: Create and Switch Branches
Recommended Services
- Fiverr - Find freelance developers and tech experts