Sitemap
Nirbhay Singh

Nirbhay Singh

Technophile, Assistant Vice President at CITI, talks about AI, DevOps, Cloud, SRE, Linux and Programming. https://buymeacoffee.com/nirbhaysingh281

Member-only story

git pull vs git fetch

2 min readOct 16, 2023

git fetch and git pull are both Git commands used to update your local repository with changes from a remote repository. However, they work differently and serve different purposes:

  1. git fetch:
  • git fetch is used to retrieve changes from a remote repository without automatically merging or applying those changes to your working branch. It only updates your local copy of the remote branches.
  • It does not make any changes to your working directory or your local branch.
  • After running git fetch, you can inspect the changes using git log or other Git commands to see what has been updated in the remote repository.
  • You can use git fetch to bring your local repository up to date with the latest changes in the remote repository without affecting your current work.
  1. Example:
git fetch origin
git pull
  • git pull is used to retrieve changes from a remote repository and automatically merge them into your current working branch. It combines git fetch and git merge in one command.
  • When you run git pull, Git fetches the changes from the remote repository and then merges them into your local branch.
  • It can result in conflicts if there are changes in both your local branch and the remote branch. You may need to resolve conflicts before Git can successfully merge the changes.
  • git pull is a convenient way to update your…

--

--

Technophile, Assistant Vice President at CITI, talks about AI, DevOps, Cloud, SRE, Linux and Programming. https://buymeacoffee.com/nirbhaysingh281