GitHub Key points — part 5
Git fetch vs Git pull
The “git fetch” command allows you to download files from a remote repository without modifying your working copy. It downloads and stores the files as a new branch.
Get Lamai Anthony’s stories in your inbox
Join Medium for free to get updates from this writer.
For example, if you want to compare your local “main” branch to the remote “main” branch repository or verify changes made by other developers to the remote branch, you can use the “git fetch” command and then checkout the remote branch.
git fetch remote mainTo view the remote branch that was fetched, run the “git branch -r” command. The branch with the remote prefix will be displayed.
origin/main
remote/mainOn the other hand, “git pull” downloads the files to your local repository and merges them with your local copy. This is because once “git pull” is run, a merge operation is initiated.
#Fetch all remotes.
git pull - all
#Fetch a limited number of commits.
git pull - depth=<depth>
#Show the action that would be completed without actually making changes to your repo.
git pull - dry-run
#Remove all remote references that no longer exist on the remote.
git pull - prune
#Do not fetch tags
git pull - no-tags








