The 'git fetch' Command
Explore how to use git fetch to safely download changes from a remote repository into your local Git environment. Understand the difference between fetching and pulling, and learn to manage remote branches and merges effectively.
We'll cover the following...
Fetching from remote
First, you will look at fetching from the remote.
The command git fetch gets the latest changes from the remote repository and copies them into the local repository, updating the local copies of any branches that have been changed.
Crucially, these changes are not mixed with your local branches but are kept in a separate place. So if you have a master branch on the remote Git repository and a master branch on your local Git repository, then your local one will not be affected.
First, make a change to the origin’s repository:
1 cd ..
2 cd git_origin
3 echo 'fetchable change' >> ...