Working with Remotes
1/9/2025
Working with Remotes
Remote repositories are versions of your project hosted on the Internet or network.
Remote Commands
bash
# List remotes
git remote -v
# Add remote
git remote add origin https://github.com/user/repo.git
# Remove remote
git remote remove origin
# Rename remote
git remote rename origin upstreamPush and Pull
bash
# Push to remote
git push origin main
# Push and set upstream
git push -u origin main
# Pull from remote
git pull origin main
# Fetch without merging
git fetch originWorking with Forks
bash
# Add upstream remote
git remote add upstream https://github.com/original/repo.git
# Sync fork with upstream
git fetch upstream
git checkout main
git merge upstream/mainPull Requests Workflow
bash
# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "Add new feature"
# Push branch
git push origin feature/new-feature
# Create PR on GitHub
# After merge, clean up
git checkout main
git pull
git branch -d feature/new-feature
Monkey Knows Wiki