Search code examples
gitgit-commitgit-loggit-fetch

"git fetch" doesn't update commit history in "git log"


I'm new to git workflow and was following a tutorial online about "git fetch". Here are the performed steps:

  1. "git pull" to synchronize files and history from remote repo
  2. A new commit was performed by the same user online
  3. "git remote show origin" show that local branch is "out of date" with remote repo
  4. "git fetch" was performed to synchronize metadata and not local files

For the tutorial --> After "git fetch" when "git log" is used to view commit history, it shows the last performed commit and who did it

For me --> After "git fetch" when "git log" is used, it doesn't show me the last performed commit

I tried "git pull" and then both commit history and local file got updated. Am I doing something wrong here (or) "git fetch" isn't supposed to update the log history


Solution

  • Yes, you have synchronized data with remote, but not change your head commit, so if you want to check remote commit log you should use git log origin/master where origin is remote name and master is name of branch that you want to show.
    If you want change yours commit to the latest from remote you should use git pull instead git fetch.