Here is the document for fetch
Fetching is what you do when you want to see what everybody else has been working on. Since fetched content is represented as a remote branch, it has absolutely no effect on your local development work.
The following example describes one of the standard methods for publishing local contributions to the central repository.
git checkout master
git fetch origin master
git rebase -i origin/master
# Squash commits, fix up commit messages etc.
git push origin master
Question>
What if I don't call git fetch origin master since it doesn't change my local development work?
If you do not fetch, then your origin/master is not updated to the latest one. Then your rebase will probably do nothing (except for the --interactive part, squash, fix-up, etc, that's up to you and can be done), being likely a predecesor to your local master.
But when you do push it will likely fail, because your local master is not a successor of the real origin/master. And that's precisely the point of doing the rebase in the first place, to make your master a successor of origin/master.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With