lab 42 Fetching Changes
- Learn how to pull changes from a remote repository.
cd ../cloned_hello git fetch git hist --all
NOTE: Now in the cloned_hello repo
$ git fetch From /Users/jim/working/git/git_immersion/auto/hello 2fae0b2..2e4c559 master -> origin/master $ git hist --all * 2e4c559 2013-04-13 | Changed README in original repo (origin/master, origin/HEAD) [Jim Weirich] * 2fae0b2 2013-04-13 | Updated Rakefile (HEAD, origin/greet, master) [Jim Weirich] * 1c23048 2013-04-13 | Hello uses Greeter [Jim Weirich] * 62d7ce0 2013-04-13 | Added greeter class [Jim Weirich] * b59a8c2 2013-04-13 | Added README [Jim Weirich] * 96ee164 2013-04-13 | Added a Rakefile. [Jim Weirich] * 0f36766 2013-04-13 | Moved hello.rb to lib [Jim Weirich] * eb30103 2013-04-13 | Add an author/email comment [Jim Weirich] * 1f7ec5e 2013-04-13 | Added a comment (v1) [Jim Weirich] * 582495a 2013-04-13 | Added a default value (v1-beta) [Jim Weirich] * 323e28d 2013-04-13 | Using ARGV [Jim Weirich] * 9416416 2013-04-13 | First Commit [Jim Weirich]
At this point the repository has all the commits from the original repository, but they are not integrated into the the cloned repository’s local branches.
Find the “Changed README in original repo” commit in the history above. Notice that the commit includes “origin/master” and “origin/HEAD”.
Now look at the “Updated Rakefile” commit. You will see that it the local master branch points to this commit, not to the new commit that we just fetched.
The upshot of this is that the “git fetch” command will fetch new commits from the remote repository, but it will not merge these commits into the local branches.
Check the README 01
We can demonstrate that the cloned README is unchanged.
$ cat README This is the Hello World example from the git tutorial.
See, no changes.