Remote Operations Cheatsheet
Remotes
| Command | Action |
|---|---|
git remote -v | List remotes with URLs |
git remote add <name> <url> | Add a remote |
git remote remove <name> | Remove a remote |
git remote rename <old> <new> | Rename a remote |
git remote set-url <name> <url> | Change remote URL |
Fetch
| Command | Action |
|---|---|
git fetch | Download from default remote |
git fetch origin | Download from origin |
git fetch --all | Download from all remotes |
git fetch --prune | Fetch + remove stale branches |
Pull
| Command | Action |
|---|---|
git pull | Fetch + merge current tracking |
git pull origin main | Pull specific branch |
git pull --rebase | Fetch + rebase (no merge commit) |
git pull --rebase origin main | Rebase pull from specific |
Push
| Command | Action |
|---|---|
git push | Push to tracking remote |
git push origin main | Push specific branch |
git push -u origin <branch> | Push + set upstream tracking |
git push --all | Push all branches |
git push --tags | Push all tags |
git push --force-with-lease | Safe force push |
git push --force | Force push (dangerous) |
git push origin --delete <branch> | Delete remote branch |
Tags
| Command | Action |
|---|---|
git tag | List all tags |
git tag v1.0.0 | Create lightweight tag |
git tag -a v1.0.0 -m "msg" | Create annotated tag |
git tag -d v1.0.0 | Delete local tag |
git push origin v1.0.0 | Push specific tag |
git push --tags | Push all tags |
git push origin --delete v1.0.0 | Delete remote tag |
Fork Workflow
| Command | Action |
|---|---|
git clone <fork-url> | Clone your fork |
git remote add upstream <url> | Add original repo |
git fetch upstream | Get upstream changes |
git rebase upstream/main | Update your branch |
git push origin main | Push to your fork |
Inspection
| Command | Action |
|---|---|
git branch -r | List remote branches |
git log main..origin/main | Commits on remote not local |
git log origin/main..main | Commits local not on remote |