Question3r
Question3r

Reputation: 3832

How to add specific Unity package to Git version?

I want to create a custom Unity package, but since I want to work on it I want to check in a whole Unity project instead of just pushing the required package files.

So normally all packages are exluced via

[Pp]ackages/

I tried this

.gitignore exclude folder but include specific subfolder

![Pp]ackages/
[Pp]ackages/**
![Pp]ackages/BroadcastCore/

and this almost seems to work. Unfortunately it tries to include the manifest.json and packages-lock.json in the Packages directory. How can I just include all the files from the BroadcastCore directory?

This is a screenshot when changing the lines from

# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/

to

[Pp]ackages/

in the .gitignore

enter image description here

Now I updated the single line with the three lines. Here you can see that it tries to include the files from the Packages directory but I think those files shouldn't exist in the remote repository

enter image description here

Upvotes: 1

Views: 543

Answers (1)

VonC
VonC

Reputation: 1328012

If it tries to include files in a folder which is supposed to be ignored, that means those files are probably already tracked.

Check this with:

git check-ignore -v -- Packages/manifest.json

If it returns nothing, it is not ignored in the first place.

Try the same command after:

git rm --cached -- Packages/manifest.json

See if removing the tracked file from Git index is enough.

Upvotes: 1

Related Questions