Skip to main content

Configuration and setup

To connect your local repository to a remote, add the remote and push your branch. For a full walkthrough, see the Create remote branches and push section.
git remote add <remote-name> <remote-repo-url>
git push -u <remote-name> <local-branch-name>

Fetching and pulling

Both git fetch and git pull download changes from the remote, but they behave differently:
FetchPull
What it doesCopies changes into your local Git repository but does not update your working directoryCopies changes and immediately updates your working directory
Formulafetch onlypull = fetch + merge

Using fetch + merge

git fetch origin <branch-name>
git merge origin/<branch-name>

Using pull directly

git pull origin <branch-name>

# Or simply, if upstream is set:
git pull
Prefer git fetch followed by git merge when you want to inspect remote changes before integrating them into your branch.

List all remote repositories

git remote -v
This shows all configured remotes and their fetch/push URLs.

Build docs developers (and LLMs) love