Skip to content

lab 39 Fetching Changes

Goals

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
   d81bcbf..e72f27a  main       -> origin/main
$ git hist --all
* e72f27a 2023-08-21 | Changed README in original repo (origin/main, origin/HEAD) [Théophile Chevalier]
* d81bcbf 2023-08-21 | Hello uses Greeter (HEAD -> main, origin/greet) [Théophile Chevalier]
* c004268 2023-08-21 | Add greeter class [Théophile Chevalier]
* 6179ba3 2023-08-21 | Added README [Théophile Chevalier]
* 9ab61ca 2023-08-21 | Moved hello.py to lib [Théophile Chevalier]
* 7abea37 2023-08-21 | Add an author/email comment [Théophile Chevalier]
* 1c410c6 2023-08-21 | Add a comment (tag: v1) [Théophile Chevalier]
* 0bf384c 2023-08-21 | Display user input (tag: v1-beta) [Théophile Chevalier]
* 31c3945 2023-08-21 | Add some content [Théophile Chevalier]
* aa5d425 2023-08-21 | First Commit [Théophile Chevalier]

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.