42. Fetching changes


  • To learn how to pull changes from a remote repository.


cd ../cloned_hello
git fetch
git hist --all

NOTE: We are now in the repository cloned_hello


$ git fetch
From /Users/marina/Documents/Presentations/githowto/auto/hello
   6e6c76a..2faa4ea  master     -> origin/master
$ git hist --all
* 2faa4ea 2011-03-09 | Changed README in original repo (origin/master, origin/HEAD) [Marina Pushkova]
* 6e6c76a 2011-03-09 | Updated index.html (HEAD, origin/style, master) [Marina Pushkova]
* 1436f13 2011-03-09 | Hello uses style.css [Marina Pushkova]
* 59da9a7 2011-03-09 | Added css stylesheet [Marina Pushkova]
* 6c0f848 2011-03-09 | Added README [Marina Pushkova]
* 8029c07 2011-03-09 | Added index.html. [Marina Pushkova]
* 567948a 2011-03-09 | Moved hello.html to lib [Marina Pushkova]
* 6a78635 2011-03-09 | Add an author/email comment [Marina Pushkova]
* fa3c141 2011-03-09 | Added HTML header (v1) [Marina Pushkova]
* 8c32287 2011-03-09 | Added standard HTML page tags (v1-beta) [Marina Pushkova]
* 43628f7 2011-03-09 | Added h1 tag [Marina Pushkova]
* 911e8c9 2011-03-09 | First Commit [Marina Pushkova]

At the moment the repository contains all the commits from the original repo, however they aren’t integrated into the local branches of the cloned repository.

You’ll find the commit named “Changed README in original repo” in the history. Notice that the commit includes “origin/master” and “origin/HEAD”.

Now let’s take a look at the “Updated index.html” commit. You’ll see that the local master branch points to this very commit, not the new commit we’ve just fetched.

This brings us to the conclusion that the “git fetch” command will fetch new commits from the remote repo, but won’t merge them into the local branches.

01Check the README

We can show that the cloned README file has not been changed.




$ cat README
This is the Hello World example from the git tutorial.

No changes, as you can see.

© 2011-2015 Git How To. All rights reserved / Contact us