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 make your change.

Running ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.