0

is it possible to have a folder ignored by git even if sometimes this folder is committed?

The background is that in open source projects I don't want others to commit the dist/ folder, however when I build a new version I need to obviously commit the dist/ folder. Is there a solution to this "problem"?

Thanks

Lukas Oppermann
  • 2,918
  • 6
  • 47
  • 62
  • 1
    Not a particularly clean solution, but you could commit `dist/`, and then just have every use assume-unchanged on it when they commit, such that no changes would come in when you don't want them (q.v. [see here](https://stackoverflow.com/questions/12288212/git-update-index-assume-unchanged-on-directory)). – Tim Biegeleisen Mar 07 '18 at 09:20

1 Answers1

-2

Even if a file is listed in .gitignore, you can use git add -f [file] to tell git to actually add it to your next commit.

Putting dist/ in your .gitignore is a way to avoid casual add + commit, and which would still allow you to commit the content when needed.

LeGEC
  • 46,477
  • 5
  • 57
  • 104