ingydotnet / git-subrepo

MIT License
3.18k stars 263 forks source link

.gitignore specific to subrepo #596

Open fherreazcue opened 10 months ago

fherreazcue commented 10 months ago

Is it possible to ignore files for the subrepo commits/pushes, but not ignore them in the main repo?

I am using git subrepo to re-use code that generates files based on some templates. The templates live in the subrepo (S), and the subrepo lives in multiple bigger repos (R1, R2...) with different directory structures. The workflow is generally to pull S from R, run a script (which also lives in S) to generate a bunch of R specific files, and then push these files to R. This would be fine if S was "read only", but if you ever try to push to S, all of the R specific files are pushed, and eventually cloned into the other R repos. I want to be able to ignore those files in S commits, say by having a .gitsubrepoignore file or config value. Also, on a force pull all the local R specific files get deleted... for my use case that is kind of ok, but it may not be for others...

I found a couple of issues (#437 & #64) that touch on a feature I could not find how to work, and I believe those issues refer more to ignoring files when pulling a subrepo only.

admorgan commented 10 months ago

No, git subrepo does not have a mechanism to ignore files other than .gitignore. Therefore it would not be possible to have files committed to the S directory in R but not pushed to S. This is also a feature I am not interested in implementing. I always look at patches, but I am not inclined to be excited about this one.

I obviously don't have any information about your projects, but I would store the output in a directory in R that does not overlap the S directory. Then you have the tools to generate them, but not trying to filter the output. To be honest in my work projects I don't allow committing the output of something that can be compiled (I count scripts that generate output of any sort as compiling).