'Git - nullSha1: contains entries pointing to null sha1

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?

git


Solution 1:[1]

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.

Solution 2:[2]

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>'

Solution 3:[3]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 ryenus
Solution 3 Alex R