halloleo halloleo - 4 months ago 41
Git Question

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

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 repository, but a few I want to keep in my local repository only (they contain mildly sensitive information).

How can I achieve this with git? Can I configure a "

" file? I cannot use the local
file, because it would exclude these files completely from being tracked.

ps: I am aware of question Is there an exclude file-equivalent..., but the answer goes down the
path which I cannot use. The other question Exclude specific files when pushing... answers only a specific case for git+heroku, not git alone.


This is not possible. If you have committed a file, then it will be pushed. The push action only acts on commits, not on a file basis.

But you could use a submodule for your sensitive data and keep this submodule on your local machine, while you push the regular git repository to the remote machine.