Git Remotes
Manage upstreams, fetch, pull, and push with tracking branches.
- git remote
- git fetch
- git pull
- git push upstream
- git prune
Git Remotes
Manage upstreams, fetch, pull, and push with tracking branches.
Commands
| Command | What it does |
|---|---|
git remote -v | Show fetch/push URLs |
git remote add upstream <url> | Track the original project repo |
git fetch --all --prune | Download refs, drop deleted remote branches |
git pull --ff-only | Update current branch, fail instead of merging |
git push -u origin <branch> | Push and set upstream tracking |
git ls-remote | List remote refs without cloning |
Example
git remote add upstream https://github.com/org/app.git
git fetch upstream --prune
git push -u origin feature/search
FAQ
fetch vs pull?
fetch only downloads refs; pull = fetch + merge/rebase into your branch.
What does -u do on push?
It links the local branch to the remote one, so later git pull/push need no arguments.
Câu hỏi thường gặp
fetch vs pull?
fetch only downloads refs; pull = fetch + merge/rebase into your branch.
What does -u do on push?
It links the local branch to the remote one, so later git pull/push need no arguments.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.