Skip to main content

What happens by default with git pull?

By default, git pull performs two operations in a row:

git fetch + git merge

That is, Git:

  1. fetches the changes from the remote repository
  2. merges them into the current local branch via merge

Let's break it down step by step

When you run:

bash
git pull

Git does the following:

1. git fetch

  • downloads new commits from the remote repository
  • does not touch your working code
  • updates the remote references (origin/main, origin/dev, etc.)

2. git merge

  • takes the corresponding remote branch
  • merges it into the current local branch
  • creates a merge commit if needed

Merge is exactly what is used by default.


Example

You are on the main branch:

bash
git pull

This is equivalent to:

bash
git fetch origin git merge origin/main

What happens to the history

  • the history is not rewritten
  • a merge commit is possible
  • if there are conflicts, Git stops and asks you to resolve them

Important point (often asked)

git pull does NOT rebase by default

If you want rebase, you need to specify it explicitly:

bash
git pull --rebase

or configure it in the config.


Short answer for an interview

By default, git pull runs git fetch, then git merge, merging the changes from the remote branch into the current local one without rewriting history.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.