lab 40 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/opsparkowl/Documents/opspark/dev_shop/git-immersion/auto/hello c6d9ed3..21df587 main -> origin/main $ git hist --all * 21df587 2019-06-27 | Changed README in original repo (origin/main, origin/HEAD) [Halle Bot] * c6d9ed3 2019-06-27 | Updated package (HEAD -> main, origin/greet) [Halle Bot] * 56af19d 2019-06-27 | Hello uses Greeter [Halle Bot] * 1e7679d 2019-06-27 | Added greeter class [Halle Bot] * 3aa3064 2019-06-27 | Added README [Halle Bot] * 2b04803 2019-06-27 | Added a package.json. [Halle Bot] * b65b430 2019-06-27 | Moved hello.js to lib [Halle Bot] * 4535421 2019-06-27 | Add an author/email comment [Halle Bot] * 59992ce 2019-06-27 | Added a comment (tag: v1) [Halle Bot] * 20a6c79 2019-06-27 | Added a default value (tag: v1-beta) [Halle Bot] * 6915d41 2019-06-27 | Using process.argv [Halle Bot] * 284070d 2019-06-27 | First Commit [Halle Bot]
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/main” and “origin/HEAD”.
Now look at the “Updated package.json” commit. You will see that it 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.