Git: Fetch and Pull
Fetching and pulling are used to get updates from a remote repository. The key difference is how they integrate those changes.
Fetch Changes
Basic Fetch
Fetch changes from remote
git fetch [remote]Downloads commits, files, and refs from a remote repository into your local repository without automatically merging them. This lets you inspect the changes before integrating them.
Fetch and prune
Fetch changes and remove deleted branches
git fetch --prune [remote]This command fetches changes from the remote and removes any remote-tracking references that no longer exist on the remote.
Pull Changes
Pull changes from remote
git pull [remote] [branch]Fetches changes from a remote and immediately merges them into your current branch. Like `git push`, if you don't specify [remote] and [branch], it defaults to your upstream branch.