7.3 Keeping Up-to-Date

Cloning gets you the history of a repository up to the point you clone it, but other developers will still be making changes and updating the repository with those changes after you clone it. You need to fetch those changes from the remote repository. You do this by using the git fetch command.

Fetching changes updates your remote branches. You can see your local branches when you run git branch. If you add the -r parameter, Git shows you the remote branches:

 
​prompt> git branch -r
 
​ origin/HEAD​
 
​ origin/master​

You can check out those branches like a normal branch, but you should not change them. If you want to make a change to them, create a local branch from them first, and then ...

Get Pragmatic Version Control Using Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.