Fetching Changes
Goals
- Learn how to pull changes from a remote repository.
Execute:
cd ../cloned_hello
git fetch
git hist --all
NOTE: Now in the cloned_hello repo
Output:
$ git fetch
From /Users/jim/Downloads/git_tutorial/work/hello
e0cc19e..b39ac69 master -> origin/master
$ git hist --all
* b39ac69 2020-06-20 | Changed README in original repo (origin/master, origin/HEAD) [Jim Weirich]
* e0cc19e 2020-06-20 | Updated Rakefile (HEAD -> master, origin/greet) [Jim Weirich]
* 046088a 2020-06-20 | Hello uses Greeter [Jim Weirich]
* 3db0ffe 2020-06-20 | Added greeter class [Jim Weirich]
* 8d90176 2020-06-20 | Added README [Jim Weirich]
* 5aec14d 2020-06-20 | Added a Rakefile. [Jim Weirich]
* 721b979 2020-06-20 | Moved hello.rb to lib [Jim Weirich]
* 907a445 2020-06-20 | Add an author/email comment [Jim Weirich]
* 4254c94 2020-06-20 | Added a comment (tag: v1) [Jim Weirich]
* c8b3af1 2020-06-20 | Added a default value (tag: v1-beta) [Jim Weirich]
* 30c2cd4 2020-06-20 | Using ARGV [Jim Weirich]
* 4445720 2020-06-20 | 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.
Execute:
cat README
Output:
$ cat README
This is the Hello World example from the git tutorial.
See, no changes.