"Fatal: bad object" error using git subtree push

This is a noob question but I'm under the gun to resolve this. I've inherited an odd problem with a git subtree that appears to be repo corruption.

Here's the scenario : a subtree of a git-based project A is being used in project B. Part of the deploy script use pushes the subtree out to project B's repo:

git subtree push -P sub/path/name --squash git@github.com:MyCo/project_b.git projectb_branch

it starts pushing the commits and fails with

"fatal: bad object {sha}" 

I've searched for the SHA in the source repo's git log. It shows up in a commit:

git-subtree-dir: app/assets/ui
git-subtree-split: {sha}

The target repo (project_b) does indeed have a commit with that SHA but the source repo does not. I walked through the subtree shell script I can see that it's failing when it tries to look up that object with git log (in the toptree_for_commit function calling git log -l --pretty=format:'%T' {sha}).

At this point I am in way over my head but eager to try to find a solution. I've researched this as far as my limited knowledge permits, so I welcome any tips, tricks or RTFMs that can get me a little closer to a solution.

my sincere thanks!

Answers


I just ran into this issue and was able to resolve by:

git remote add shared $url
git fetch shared
git subtree push -P $prefix shared $branch

Might not help for all but saved me from having to hack on the repo structures.


I came across similar issue: git subtree push ... used to work on the computer, where I did git subtree add ..., but wouldn't work on second computer:

$ git subtree push --prefix lib git@github.com:lib/lib.git master
...
...
fatal: bad object {sha} 

Fix was to pull changes from the repository first (even though there were no changes):

git subtree pull --prefix lib git@github.com:lib/lib.git master

and even though it didn't pull anything, push worked fine then:

git subtree push --prefix lib git@github.com:lib/lib.git master

I have figured this out; I found the reference of the errant sha in the commit information.

The easiest way to fix this is to:

  • stop using the subtree split that'd been created,
  • move the content to a different subdirectory and then
  • resplit the subtree.

Kind of messy but much less error prone than backing out commits to the problematic commit and then reapplying them (suggested in an answer to a somewhat similar question).

Not beautiful, but it got the job done.


git pull worked for me. If your current branch is not a remote one, make it a remote branch using

`git push -u origin <branchname>`

Need Your Help

CrawlerProcess vs CrawlerRunner

python web-scraping scrapy

Scrapy 1.x documentation explains that there are two ways to run a Scrapy spider from a script:

Solr - Getting facet counts without returning search results

solr faceted-search

I need to return only the facet counts from solr. So I basically want to search over all documents and return the facet counts, but I don't want to return any search results. Is this possible?