Using git to track only some of a Unity project

2019-06-14 19:42发布

I've been using git to work on a Unity project, but I've found I don't really want to check the the whole project into source control all the time. I have a bunch of plugins downloaded that I expect to delete later and I don't want to bring them into my git history.

Are there any files in Unity that I need to keep checked in or am ok to just version the stuff I'm working on. I'm still getting the hang of git so this may be as much about version control best practices as it is about Unity. For example, does it matter if I check in my Scene files or is there any reason they might get out of sync if I don't.

I feel like just checking in the files I want is the correct approach, I just want to make sure I'm not going to cause myself problems later.

For example, in the Assets folder i have:

downloadedLibrary1/
bunchOfTestScenes/
scriptsIwantToKeep/

If I use git to only watch the scriptsIWantToKeep/ folder is that going to cause me problems now or down the road or is that the correct way I should be using git in the first place?

1条回答
SAY GOODBYE
2楼-- · 2019-06-14 20:18

You can use a sparse checkout to pull only the folders you want, if you declare them in a .git/info/sparse-checkout file.

There can be some issue with subsequent git pull (as shown in this 2012 question), but if you are using a recent 1.9.x version of git, updates of a sparse checkout should work just fine.

You can then "watch" those specific folders by doing regultar git pull, and git log -- aFolderYourWatch, in order to see the history of commits impacting those specific folders.

查看更多
登录 后发表回答