Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate gitignore files for Heroku and GitHub?

I have one file that is necessary for my heroku app but that I do not want in my GitHub repository.

Is there any way to have a .gitignore that is only used when pushing to GitHub?

Additionally, is there any other way that I can avoid pushing that one file to GitHub?

like image 426
Mike Avatar asked Oct 27 '22 13:10

Mike


1 Answers

If you have already tracked this file, removing it (and even ignoring it in a .gitignore) before pushing to GitHub will not remove it from the history of that pushed repository.

That means it is important to know why you do not want that file on GitHub.

If it is for security reason, because it includes sensitive information, you might have:

  • more work to do
  • to externalize that file outside of any local repository to be sure it won't be included.

More generally, no, there is no conditional/separate .gitignore for two different remote repository.

In your case, you might have to script your git push operation in order to play with, as in here, to play with git update-index --(no-)assume-unchanged <file>.

like image 157
VonC Avatar answered Nov 17 '22 06:11

VonC