Question: I have a remote repo in which I want to commit certain files (the compiled files to deploy them on a cloud computing platform), but I don't want to deploy them on github...

is there some way to have to different .gitignore files, one for each remote?

Answer: 
**Update:** you will not be able to replicate this environment using git clone, so I don't think this is a good approach

---

I figured out a way to do this.

In my case, I needed to synchronize the project with heroku and GitHub (as my public repo).

But I was not interested in sharing some files with private information in a public repository.

Usually a simple project would have the following folder structure

```
Project folder (remote heroku)
    - .git
    - .gitignore
    - (folders and files)

```

What I did was add one more level, and in it create another git repository, with a `.gitignore` that would omit some files from my project.

```
Project public (remote GitHub)
    - .git
    - .gitignore
    - Project folder (remote heroku)
        - .git
        - .gitignore
        - (folders and files)

```

So this is not a git repository with two remote repositories with different `.gitignore`s.

There are two different repositories.

On the innermost I only exclude the files generated by the IDE and some files generated at runtime.

At the outermost level, I exclude all files that cannot be make public.
Another option is [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).

This can be useful if, for instance, you want your code and documentation to be in two different repos with independent access control, etc. So you'd have 3 total repos, a submodule repo for docs, another for code, and the "master" (not a git submodule) repo containing both (for pypi upload, perhaps). This is a decent way to organize a CS textbook project. Both projects can proceed merrily ahead independently and sync up at major releases, driven by the master repo maintainer.