git fetch vs git pull code example
Example 1: git fetch vs pull
Git Fetch ==>The Git Fetch command
downloads commits, files from a remote
repository into your local repo.
Fetching is what you do when you want
to see what everybody else has been working on
Git Pull ==> fetch and merge any
commits from the remote branch
Example 2: git pull or fetch difference
git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn’t do any file transferring. It’s more like just checking to see if there are any changes available).
git pull on the other hand does that AND brings (copy) those changes from the remote repository.
Example 3: what does git fetch do
The git fetch command downloads commits, files, and refs from a
remote repository into your local repo. Fetching is what you do
when you want to see what everybody else has been working on.
... When downloading content from a remote repo,
git pull and git fetch commands are available to accomplish
the task.
Example 4: git pull vs rebase
git pull fetches the latest changes of the current branch from a remote and applies those changes to your local copy of the branch.
Generally this is done by merging, i.e. the local changes are merged into the remote changes. So git pull is similar to git fetch & git merge.
git pull --rebase :
The local changes you made will be rebased on top of the remote changes, instead of being merged with the remote changes.