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/tonywok/src/git_immersion/auto/hello d9d52f1..709e4e5 master -> origin/master $ git hist --all * 709e4e5 2020-05-30 | Changed README in original repo (origin/master, origin/HEAD) [Jim Weirich] * d9d52f1 2020-05-30 | Updated Rakefile (HEAD -> master, origin/greet) [Jim Weirich] * 7226fee 2020-05-30 | Hello uses Greeter [Jim Weirich] * bd0e5fa 2020-05-30 | Added greeter class [Jim Weirich] * 32cb785 2020-05-30 | Added README [Jim Weirich] * 128a484 2020-05-30 | Added a Rakefile. [Jim Weirich] * a3cf03d 2020-05-30 | Moved hello.rb to lib [Jim Weirich] * 96c1fec 2020-05-30 | Add an author/email comment [Jim Weirich] * 9811d9e 2020-05-30 | Added a comment (tag: v1) [Jim Weirich] * 3344f03 2020-05-30 | Added a default value (tag: v1-beta) [Jim Weirich] * 3cb4c15 2020-05-30 | Using ARGV [Jim Weirich] * dfb5614 2020-05-30 | First Commit [Jim Weirich]
At this point the repository has all the commits from the original repository, but they are not integrated into 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 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
We can demonstrate that the cloned README is unchanged.
$ cat README This is the Hello World example from the git tutorial.
See, no changes.