The tree contains an entry with an invalid path '.git'

I am currently migrating projects from Team Foundation Version Control to Git . I have successfully done this twice using git-tf to upload the code to the local git repository, and then drag this repository to the new remote repository.

In my third project, I get the following error when trying to click:

error: unpack failed: error The tree e934502276892b903347a524cb066a14a19d8ac0 object was rejected: the tree contains an entry with the wrong relative path '.git'.

I can’t understand what it can be when it fails, when I click on TFS or GitHub . I would be so grateful if anyone has an idea how to fix it.

Thanks!

+1
git
source share
2 answers

For some security reasons, Git refuses to store files in any directory named .git . (If Git allowed .git files, a file named .git/hooks/commit in the Git repository would be your commit commit, and the next command you would run would launch any arbitrary commands that the attacker placed in that file. Make sure this did not happen, but it turned out that it was slightly broken.) For specific, specific reasons, this particular security problem manifests itself as a bad "tree object" that contains ".git", which is configured through hasDotGit . one

However, not every version of Git has all the tests, and as new problems have been discovered over the years, new versions of Git have gained new protection against these old problems. If you have an older version of Git installed, your Git may allow the storage of unsafe and / or incorrect elements, such as this bad tree object. Upgrading to a newer version of Git or accessing a newer version of Git on a server will sometimes diagnose or even begin to refuse to work with a bad repository.

Starting with Git version 2.6, you can configure Git to accept certain elements of a bad repository , even if you have enabled verification in general. (Prior to 2.6, you should simply disable verification completely.) You can ignore some problems, lower some problems to the warning level, update warnings to errors, and / or ignore some specific objects by their hash identifiers. This configuration must be done on the server; no matter how, and how, it can be done on the servers you use, I do not know. See also this post in the GitLab community , which says that something or someone has disabled this for a long time.

For reference, Git versions 2.2.1, 2.1.4, 2.0.5, 1.9.5, and 1.8.5 were the points at which Git started checking .git written to NTFS and MacOS (HFS) and with case insensitivity (up to of this .git or .git or .git , for example, were all accepted as OK, which are usually found on Linux / Unix systems). These checks are located in fsck.c and, if necessary, are activated in all processes of loading, downloading and indexing packages. See the git config documentation, look for every instance of fsck , as there are numerous configuration buttons to enable or disable the check completely or change the severity of the problems.

To reduce the severity of hasDotGit to warning , you should:

 $ git config fsck.hasDotGit warning 

inside this particular repository.

Besides reconfiguring the servers, you can also rewrite the history of the bad repository (using git filter-branch ) to turn it into a good repository. If you do this, you will essentially force all your users to re-clone.


1 The exact form of the text message is internationalized, but by default it contains '.git' , and the configuration line hasDotGit .

The configuration lines are not obvious and do not seem to be properly documented. They are formed by using the enumerated names in the fsck.c source and removing all underscores and lowercase, and then the inverted end you like to make camelCase names. (Comparing git config strings is case-insensitive, so you can configure fsck.hasdotgit or fsck.hasdotgit if you want. CamelCase is just a convention.)

+2
source share

So, I realized what the problem is. Two years ago, the Git repository was added to the directory and registered in TFS. It has been deleted again and registered. It seems that since my Git repository has a history of this, it throws an error due to the reasons described by torek.

My solution was to truncate the story to the date after this registration, and all this after that stopped.

thanks for the help

0
source share

All Articles