git: have different .gitignore file for each remote

后端 未结 4 1107
温柔的废话
温柔的废话 2020-12-04 14:57

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...

4条回答
  •  难免孤独
    2020-12-04 15:47

    I figure out a way to do this.

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

    But some files with private information were not interesting to be shared 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 gitignores.

    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 can not be make public.

提交回复
热议问题