6

I'm trying to deploy an app and I get a error. Following research pointed me here:

warning in tree f148931b374ad1aa9748b8f91bd48fcb44fb73b0: nullSha1: contains entries pointing to null sha1
Checking object directories: 100% (256/256), done.
broken link from    tree f148931b374ad1aa9748b8f91bd48fcb44fb73b0
              to    blob 0000000000000000000000000000000000000000
missing blob 0000000000000000000000000000000000000000 

Tried the solution here but the commands do nothing on terminal they just sit there.

Can somebody help me?

Community
  • 1
  • 1
Bruno Teixeira
  • 565
  • 4
  • 11
  • 25
  • Possible duplicate of [How to remove an entry with null sha1 in a Git tree](https://stackoverflow.com/questions/24183847/how-to-remove-an-entry-with-null-sha1-in-a-git-tree) – Jess Bowers Oct 19 '17 at 21:42

3 Answers3

3

You could try, as suggested here, to remove the commit with the null sha1, using git filter-branch

git ls-tree f148931b374ad1aa9748b8f91bd48fcb44fb73b0
<an element>
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <an element path>'  --prune-empty --tag-name-filter cat -- --all

Replace <an element path> by the path relative to the root folder of the repo of the element returned by git ls-tree.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Just for the record, these days git filter-repo is the officially recommended alternative to git filter-branch, which is newer, safer and faster.

Tl;dr

First use git ls-tree --full-name <treeish> to find the path of the bad object(s)/file(s), then use git filter-repo --invert-paths to rewrite the history commits and remove the bad file(s).

Example usage of git filter-repo for removing objects

git filter-repo --invert-paths --path '<path-to-file1>' --path '<path-to-file2>`

Or use option --path-glob, or --path-regex to match files with a pattern:

git filter-repo --invert-paths --path-glob '<glob>` --path-regex '<regex>'
ryenus
  • 15,711
  • 5
  • 56
  • 63
0

I got this error while trying to setup a project to use submodules. Getting rid of the submodules fixed the error.

Alex R
  • 11,364
  • 15
  • 100
  • 180