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

CommandWhat it does
git remote -vShow fetch/push URLs
git remote add upstream <url>Track the original project repo
git fetch --all --pruneDownload refs, drop deleted remote branches
git pull --ff-onlyUpdate current branch, fail instead of merging
git push -u origin <branch>Push and set upstream tracking
git ls-remoteList 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.

Întrebări frecvente

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