How to solve git error: Server does not allow request for unadvertised object 3a2ceef391af73994dfeb0d8ef57ed6a52ef4238?
Asked Answered
L

14

22

I wanted to pull commit "3a2ceef391af73994dfeb0d8ef57ed6a52ef4238" from branch android. I used the command:

$ git fetch origin 3a2ceef391af73994dfeb0d8ef57ed6a52ef4238

and it is showing this error,

error: Server does not allow request for unadvertised object 3a2ceef391af73994dfeb0d8ef57ed6a52ef4238

How to solve this problem?

Lamellicorn answered 23/6, 2018 at 14:3 Comment(1)
O, in a youtube tutorial I saw this :(Lamellicorn
O
12

According to this answer and the given source it looks like BitBucket does not allow you to fetch a commit id, only references.

I cannot say if you can configure this behavior, but I think you can:

  1. Pull the branch: git pull origin branchname
  2. Checkout the local commit id: git checkout <commitid>
Omniumgatherum answered 23/6, 2018 at 14:21 Comment(0)
D
22

git submodule sync as pointed in https://github.com/AppImage/AppImageKit/issues/511 works for me.

Dietitian answered 20/11, 2019 at 3:12 Comment(0)
O
12

According to this answer and the given source it looks like BitBucket does not allow you to fetch a commit id, only references.

I cannot say if you can configure this behavior, but I think you can:

  1. Pull the branch: git pull origin branchname
  2. Checkout the local commit id: git checkout <commitid>
Omniumgatherum answered 23/6, 2018 at 14:21 Comment(0)
D
7

I got the same error and none of these resolved it. It turned out that I hadn't pushed submodule changes from my other computer (this would give 404 error when you click on submodule folder on GitHub). So pushing submodule, committing parent and pushing that as well resolved the error.

Other solutions are git submodule update --recursive and this.

Deedee answered 31/10, 2019 at 3:56 Comment(0)
G
6

I got the same error when use git submodule update --init,quickly fix it by using git submodule update --force --recursive --init --remote

Gypsum answered 7/1, 2021 at 9:31 Comment(0)
E
4

use fetch option --no-recurse-submodules

examples:

    git fetch -q origin refs/tags/*:refs/tags/* --no-recurse-submodules
    git fetch --no-recurse-submodules --no-tags origin 
    git fetch --no-recurse-submodules origin $GERRIT_BRANCH 


While this example is not explicitly stating the commit, I see this error occasionally when doing a git fetch on a repo containing submodules where the submodule contains a commit that is unadvertised.


The error:
"Server does not allow request for unadvertised object 5665ef0fb603a7d1e5a402763c0f2f049623012a"
can be traced back to the git version.
I first saw this error on upgrade to git version 2.22.0. When I rolled the version back to 2.20.0, no error.
Rolling back the git version could also be used as a temporary workaround if you are looking for a quick solution.

Extremism answered 5/12, 2022 at 15:14 Comment(0)
C
3

This can happen when you are pointing to submodule commit that has been removed through a history re-write or squash. The best you can do is:

  • First get a clear picture of what your team has been doing so you know what it should look like.
  • Update your local with a git pull and then find the closest commit that works with your branch (it may be the latest) and then add that to your parent repo. e.g. something like:
parent-repo$ git fetch
parent-repo$ cd submodule-a
submodule-a$ git pull
submodule-a$ git checkout best-commit-according-to-team-and-your-branch
submodule-a$ cd ../
parent-repo$ git status
...
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:  submodule-a (modified content)
...
git add submodule-a
git commit -m "updated submodule-a reference"

Once you are happy it is correct and your team agrees you can push it up and the error should go away.

Ceja answered 27/7, 2020 at 5:10 Comment(0)
M
2

When I run:

git submodule update

or

git submodule update --init --recursive

I got the error:

error: Server does not allow request for unadvertised object xxxxxxxxx

Fetched in submodule path 'xxx', but it did not contain xxxxxxxxx.Direct fetching of that commit failed.

And I fixed this problem by :

git submodule update --remote
Mervin answered 25/4, 2021 at 6:50 Comment(0)
S
1

I was facing such an error while doing a git pull. Doing below helped fix the issue for me.

git remote prune origin
git pull
Scrawny answered 9/4, 2020 at 21:16 Comment(0)
G
1

I got the same problem and unsuccessfully tried some of the above solutions. What worked for me is:

git fetch --unshallow && git fetch origin && git reset --hard origin/master
Grof answered 8/1, 2021 at 9:10 Comment(0)
M
1

The fact that there are so many different answers where some work and most of them don't is really showing that Git is not stable and too complex for such an easy task. I wonder if the Git architects are able to read this without any embarressment.

Having said that, the following worked for me:

git clone --recurse-submodules [email protected]:company/mytoprepo.git .

The above does give the error "Server does not allow request for unadvertised object", but just ignore that.

Then do the following:

cd submoduleDirectory
git fetch origin
git reset --hard origin/master

The last command finally gets all the files of the submodule.

Please let me know when this does not work for you. It might be good to increase the embarressment for the Git Architects. Maybe they start making the Git utility more Simple. (That's a concept you don't hear often in IT nowadays: Making stuff Simpler...) :-)

Manufacture answered 7/4, 2021 at 11:17 Comment(0)
C
1

This can also happen if you squash commits when you merge a pull request. The id of the commit that is referenced by the parent can be removed during a squash. Be sure to do a regular merge of your pull request if the commit id needs to be retained.

Canning answered 16/4, 2021 at 22:18 Comment(0)
S
1

This can happen simply if the commit hash/id you are trying to checkout does not exist in the repository. For example if you accidentally are in the wrong folder (git repo) when you paste the hash as part of the git checkout command.

Slunk answered 9/6, 2021 at 0:31 Comment(0)
D
0

You can follow the below steps to solve the above error .

> git init 
> git pull <reponame> branchname(optional) 
> git reset --hard <commit_id>

Note:make sure that You have committed and pushed your changes from local to remote already as reset --hard will leave any unsaved changes from local and it moves completely and get the files and folders of the commit which is irreversible with any changes not pushed. You may have a look in to these as well.

https://www.pylabz.com/2019/08/using-python-to-pull-files-of-git-hub.html#more

https://medium.com/@deepakr6242/using-python-to-extract-files-from-git-hub-repo-through-commits-id-2bdf76b2e0fd

Dressmaker answered 19/8, 2019 at 5:39 Comment(0)
C
0

In my case, I forgot to git push submodule commit.

Cristal answered 20/12, 2023 at 2:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.