MEPX
Chapter 9 of 14All chapters

Chapter 9 of 14

Fetch, pull and push

Moving commits between copies.

Fetch before you pull

git fetch downloads new commits and updates your view of the remote without touching your branch. git pull is a fetch followed by a merge, so it can change your files and can conflict.

  • Fetch is always safe, which makes it the habit worth having.
  • git pull --rebase replays your local commits on top instead of merging.

Pushing

git push sends your commits up and is refused if the remote has commits you do not have. Fetch and integrate first rather than reaching for --force, which overwrites other people's work.