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/alex/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) [Alexander Shvets] * 6e6c76a 2011-03-09 | Updated index.html (HEAD, origin/style, master) [Alexander Shvets] * 1436f13 2011-03-09 | Hello uses style.css [Alexander Shvets] * 59da9a7 2011-03-09 | Added css stylesheet [Alexander Shvets] * 6c0f848 2011-03-09 | Added README [Alexander Shvets] * 8029c07 2011-03-09 | Added index.html. [Alexander Shvets] * 567948a 2011-03-09 | Moved hello.html to lib [Alexander Shvets] * 6a78635 2011-03-09 | Add an author/email comment [Alexander Shvets] * fa3c141 2011-03-09 | Added HTML header (v1) [Alexander Shvets] * 8c32287 2011-03-09 | Added standard HTML page tags (v1-beta) [Alexander Shvets] * 43628f7 2011-03-09 | Added h1 tag [Alexander Shvets] * 911e8c9 2011-03-09 | First Commit [Alexander Shvets]
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.