Skip to content

lab 50 Fetching Changes

Goals

Execute:

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

NOTE: Now in the cloned_hello repo

Output:

$ git fetch
$ git hist --all
* 71425e9 2022-10-24 | Add excitement (origin/excitement) [Jim Weirich]
*   b1df40e 2022-10-24 | Merge branch 'main' into greet [Jim Weirich]
|\  
* | 18e7dbd 2022-10-24 | Updated Rakefile [Jim Weirich]
* | 2a024f1 2022-10-24 | Hello uses Greeter [Jim Weirich]
* | 85316c2 2022-10-24 | Added greeter class [Jim Weirich]
| | * 62eac9b 2022-10-24 | Updated Rakefile (origin/greet) [Jim Weirich]
| | * 7a0c973 2022-10-24 | Hello uses Greeter [Jim Weirich]
| | * 5729241 2022-10-24 | Added greeter class [Jim Weirich]
| |/  
| | * a3d1a30 2022-10-24 | Updated Rakefile (origin/main) [Jim Weirich]
| | * 2a07cf7 2022-10-24 | Hello uses Greeter [Jim Weirich]
| | * 09b3f43 2022-10-24 | Added greeter class [Jim Weirich]
| |/  
| * 62f7394 2022-10-24 | Added README [Jim Weirich]
|/  
* 0022837 2022-10-24 | Added a Rakefile. [Jim Weirich]
* 3172288 2022-10-24 | Moved hello.rb to lib [Jim Weirich]
* 3e56dbf 2022-10-24 | Add an author/email comment [Jim Weirich]
* 1dee7f9 2022-10-24 | Tell user how many names they have (tag: v1) [Jim Weirich]
* c72af6b 2022-10-24 | Rename variable to match its usage (tag: v1-beta) [Jim Weirich]
* 8cdd2cd 2022-10-24 | Can specify multiple names [Jim Weirich]
* 28fe396 2022-10-24 | Added a comment [Jim Weirich]
* 15c7573 2022-10-24 | Added a default value [Jim Weirich]
* 7d55044 2022-10-24 | Using ARGV (HEAD) [Jim Weirich]
* 91b926e 2022-10-24 | 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/main” and “origin/HEAD”.

Now look at the “Updated Rakefile” commit. You will see that the local main 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.