Current HEAD not being retrieved from the remote
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
While performing a Git clone/fetch/pull, users can experience an issue where the latest commit is not being retrieved from the remote repository.
Environment
Bitbucket Cloud
Diagnosis
Navigate to the affected repository on the Bitbucket UI, and check if the missing commit is shown as the HEAD of the repository.
While cloning the repository locally, you only see the second last commit:
1
2
3
4
5
6
$ git log --pretty=oneline
52d37011f17cff0714a0ac07ad89120558b7187d (HEAD -> master, origin/master, origin/HEAD, neworigin/master) Adding PDF file
4df2a2d5066c4e6376b2fbd6256daaf217f8a9ae Init LFS
704f320ccd1856c11ffbb553a31314ed88c0055b Commit
cdd2b9e9a32e9a1a20d101c0e47748579b6d17db Hello 3
e4062910a00ece9e550eca3aa60e8a0cbb837713 First commit
If a git pull/fetch command is performed, the current HEAD still isn't retrieved from the remote.
3. You can also confirm that the remote is reporting the wrong HEAD using the GIT_TRACE_PACKET=1 Git flag and looking for the specific branch ref:
1
2
3
4
5
6
$ GIT_TRACE_PACKET=1 git clone https://bitbucket.org/<workspace>/<repository>.git
17:57:11.726322 pkt-line.c:80 packet: git< 52d37011f17cff0714a0ac07ad89120558b7187d refs/heads/master
17:57:11.731796 pkt-line.c:80 packet: git> 52d37011f17cff0714a0ac07ad89120558b7187d refs/heads/master
17:57:11.751625 pkt-line.c:80 packet: fetch-pack< 52d37011f17cff0714a0ac07ad89120558b7187d refs/heads/master
17:57:11.752765 pkt-line.c:80 packet: fetch-pack< 52d37011f17cff0714a0ac07ad89120558b7187d refs/heads/master
17:57:11.756035 pkt-line.c:80 packet: fetch-pack> want 52d37011f17cff0714a0ac07ad89120558b7187d
In this case, we can see that Bitbucket is still reporting the 52d37011f17cff0714a0ac07ad89120558b7187d commit as the HEAD, instead of the latest one d50fe8ce363d0055bd74459b463d1687f43c66b5.
Cause
This issue is caused due to incorrect cache invalidation on the remote. After every push, the cache for the current HEAD of each ref should be updated, but sometimes it is possible for the invalidation to not happen, due to the complex nature of cache invalidation.
This issue may also be tracked through this public bug ticket - you may Watch this bug ticket for future updates related to it
Solution
Perform a new push with any changes to any branch in your repository. This will retrigger the internal cache invalidation process, updating the current HEAD of your branch, and cause the commit to update and become available for pull.
Was this helpful?