Git: Not seeing commits with "git log" in local repo after having "git fetch"ed

Viewed 25

My Bitbucket remote has these latest commits:

Commit  Message     Commit date
d9578f5f628 Version ***NO_CI***     3 days ago  
3f3aebefcd0 Added files for git build       3 days ago  
dab48971291 Version 22.1.0.0113 ***NO_CI***     6 days ago  
8b63be0cb15 Version 22.1.0.0112 ***NO_CI***     6 days ago  

(copied from the web interface commit log)

Locally, I cannot see the latest 2 commits:

> git log --all --oneline -5
5cc97e6108 (HEAD -> default) Version 22.1.0.0114 ***NO_CI***
dab4897129 (origin/default, origin/HEAD) Version 22.1.0.0113 ***NO_CI***
8b63be0cb1 Version 22.1.0.0112 ***NO_CI***
396e33eab1 Version 22.1.0.0111 ***NO_CI***
af86c6a0d9 Version 22.1.0.0110 ***NO_CI***

Even though I successfully (?) fetched before:

> git fetch ssh://[url masked]
From ssh://[url masked]
 * branch                  HEAD       -> FETCH_HEAD

What am I missing? I might have done some bad things with git reset earlier. Not an experienced gitter.

PS: I don't want to update my working copy. Just check what latest commits are in the repo.

1 Answers

When using git fetch this way (with a raw URL instead of a remote name), you must change a lot of things about how you use Git, as ElpieKay noted in a comment that links to Having a hard time understanding git-fetch. In particular, after this git fetch, you would need to use git log FETCH_HEAD. The --all flag to git log means all refs, but FETCH_HEAD is peculiar:

  • it's sometimes a "pseudo-ref" (as are the other non-HEAD *_HEAD entities);
  • it's never included by --all here.

Other pseudo-refs will hold a single commit hash ID, but FETCH_HEAD often holds multiple lines, with each line holding a hash ID. In these cases it must be hand-parsed. As your particular git fetch output showed only one line, you won't be hitting this particular case at this particular time, but keep it in mind.

Related