Get Code from Remote Repository

There are two ways to get code from a remote repository:

1. Fetch Code

  • Downloads updates from the remote repo
  • Does not merge changes into your local branch
git fetch <remote-name>

Example:

git fetch origin

alt text


2. Pull Code

  • Downloads updates and merges them into your local branch
  • Equivalent to: git fetch + git merge
git pull <remote-name> <branch-name>

Example:

git pull origin master
alt text


Summary

  • git fetch → remote → local (no merge)
  • git pull → remote → local + merge