Git Tutorial

Fetching changes in git

Lets learn how to pull changes from a remote repository.


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

NOTE: We are now in the repository cloned_hello.


$ git fetch
From /Users/kwikl3arn/Documents/Presentations/gitdemo/auto/hello
   6e6c76a..2faa4ea  master     -> origin/master
$ git hist --all
* 2faa4ea 2020-01-09 | Changed README in original repo (origin/master, origin/HEAD) [kwikl3arn]
* 6e6c76a 2020-01-09 | Updated index.html (HEAD, origin/style, master) [kwikl3arn]
* 1436f13 2020-01-09 | Hello uses style.css [kwikl3arn]
* 59da9a7 2020-01-09 | Added css stylesheet [kwikl3arn]
* 6c0f848 2020-01-09 | Added README [kwikl3arn]
* 8029c07 2020-01-09 | Added index.html. [kwikl3arn]
* 567948a 2020-01-09 | Moved hello.html to lib [kwikl3arn]
* 6a78635 2020-01-09 | Add an author/email comment [kwikl3arn]
* fa3c141 2020-01-09 | Added HTML header (v1) [kwikl3arn]
* 8c32287 2020-01-09 | Added standard HTML page tags (v1-beta) [kwikl3arn]
* 43628f7 2020-01-09 | Added h1 tag [kwikl3arn]
* 911e8c9 2020-01-09 | First Commit [kwikl3arn]

At the moment, the repository contains all the commits from the original repo; however, they aren’t integrated into the local branches of the cloned repository.

You’ll find the commit named “Changed README in original repo” in the history. Notice that the commit includes “origin/master” and “origin/HEAD”.

Now let’s take a look at the “Updated index.html” commit. You’ll see that the local master branch points to this very commit, not the new commit we’ve just fetched.

This brings us to the conclusion that the “git fetch” command will fetch new commits from the remote repo, but won’t merge them into the local branches.

Step1:Check the README

We can show that the cloned README file has not been changed.




$ cat README
This is the Hello World example from the git tutorial.

No changes, as you can see.