I understand that you want to remove the .git folder and any files contained inside it, when you package the functions into a toolbox.
I was able to follow the procedure you mentioned and achieve this.
Steps to package a toolbox and remove the .git folder:
Step 1) Navigate to the folder that needs to be packaged as a toolbox.
Step 2) Inside MATLAB, in the Environment section of the Home tab, select Package Toolbox from the Add-Ons menu.
Step 3) Choose the folder where the files to be packaged into a Toolbox are present.
Step 4) In the Package toolbox GUI, there is a section "Toolbox Files and Folders" section, in that section please click on the "Exclude Files and Folders". This will open up a small dialog box.
Step 5) Add "**/.git" to this dialog box. In my case, this looks like:
Please note, that there is no "%" sign in front of "**/.git", otherwise it will be read as a comment. This will remove the .git folder and any files inside it from the packaged toolbox.
Step 6) Package and Install the Toolbox.
Step 7) Once, installed, navigate to the directory where the toolbox is present and it will have all the files you added except the GIT folder.
More information on how to Package a Toolbox can be found in the documentation page below:
Hope this helps.
If this still does not resolve your issue, you can create a Technical Support Request by clicking on the link below: