How to remove the ".gitattributes" file from each folder when the repository content is migrated to LFS using the BFG tool?

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

When a repository is migrated to LFS, each folder will have the ".gitattributes" file. This is a side effect of using the BFG tool.

Solution

We can leave the files as they are or remove them. There shouldn't be a problem as long as all the file patterns are tracked in the ".gitattributes" file in the root folder.

If you want to remove the additional ".gitattributes" files inside the folders, you can run the following commands locally:

1 2 3 4 $ git clone --mirror <repo URL> $ cd <repofolder.git> $ git filter-repo --invert-paths --path <path to the file to be removed> $ git push

For example, if you wanted to remove the ".gitattributes" file in the test directory, the git filter-repo command looks like below:

1 $ git filter-repo --invert-paths --path test/.gitattributes

If you don't have the "git filter-repo" tool, please refer to the installation instructions.

Please ensure to take a complete backup of the repository before making any changes. Use the following commands to take the backup:

1 2 3 $ git clone --mirror <repo URL> $ cd <repofolder.git> $ git lfs fetch --all

Updated on February 25, 2025

Still need help?

The Atlassian Community is here for you.