git - Is it possible to exclude file from `git push`, but keep them in the local repository?

前端 未结 5 1292
悲&欢浪女
悲&欢浪女 2020-12-13 09:44

In my home directory I have files in a local git repository, because I want track them all under version control.

Most of these files I want to push to a remote repo

5条回答
  •  既然无缘
    2020-12-13 10:07

    The way I eventually got around the issue is the following: Put the sensitive information in a sub directory with its own git repository and symlink the file(s) back to the old location.

    E.g. in your home folder (~) lives the file .creds which you do not want in the public repository. Move this file in a sub folder called, say protected and create a symlink from ~ to protected/.creds. Of course, do not include this folder in your ~ repository , but create a new repository in the folder protected just to keep track of .creds. If you do not push this repository publicly at all, you are set.

    I know this solution is kind of a cop out: My questions states that the file resides in the same directory, but the symlinking works for me.

提交回复
热议问题