2

Hello fellow developers.

I have a repository with a subfolder in it, containing code files used as an internal framework. Let's pretend this folder is called package.

I'm keeping this package files committed because this guarantees easier builds, and the particular framework we are using is lacking a package manager.

The files in the package folder should be mantained by a single developer (maybe on a separate branch), and updated just sparingly.

Now, I would like to prevent accidental commits on files in the package folder.

Is there a way I can achieve this task?

I'm considering different solutions:

  • git hooks; but the users could easily forget to enable them;
  • alternative package managers; but they should be really easy to add, because we already use npm and nuget and I don't want to manage too many tools;
  • git submodules; but many developers have a hard time figuring how to update/sync/etc, and the repo in which the package is built is not the same as the files that are shared. So I should manage two repos for the package, one for the development and one for the distribution.

I'm banging my head against the wall... Any suggestion would be greatly appreciated.

Thanks!

Alberto Chiesa
  • 7,022
  • 2
  • 26
  • 53
  • You can [use npm to install from a private git repo](http://stackoverflow.com/questions/10386310/how-to-install-a-private-npm-module-without-my-own-registry). You just need to have the same credentials you're using to access your main repo, given it's private too. – ffflabs Mar 16 '17 at 18:10
  • But how do I prevent commits on the package folder? Am I missing something? – Alberto Chiesa Mar 16 '17 at 20:01

1 Answers1

0

I feel this would be better as a comment, but as I can't do that yet....

For all other devs, could you not add this package directory to their .git-ignore file? And for the user maintaining it - potentially update the .git-ignore to allow the package to go through when needed and then perform another change to ignore the package directory again.

I realize this is kind of brute forcing it, but it could still be a potential solution although not the most graceful one.

Erasyn
  • 38
  • 1
  • 4
  • AFAICT, if the files are tracked inside the repository, the changes on them will be tracked even if they are matched by gitignore. Try this: commit a file, then edit gitignore to ignore it, then update his contents. Git status should show up the updated file, even if it should be ignored. To properly remove the file from the repo, you need a git rm --cached. – Alberto Chiesa Mar 16 '17 at 17:54
  • I agree with what you said. The package directory would have to be untracked by the person managing it. Alternatively, you mentioned using a separate branch, so what about [this](http://stackoverflow.com/questions/11788229/how-do-i-push-files-specified-in-gitignore) question, except replacing the vendor with your package directory? – Erasyn Mar 16 '17 at 18:14