Domanda

Is there any good way to handle permission to single files in git repository?

I have .net project which I want to share with my team. What I don't want to share are connection strings to production db, storage and so on.

I know I could create new branch with these files, but it's getting much more complicated.

È stato utile?

Soluzione

You shouldn't add sensitive data to your repository to start with. Instead, add the respective filenames to .gitignore so you never accidentally commit them.

If you really have to have the files in the repository, use a githook to encrypt the files before committing and decrypt on checkout only if the correct key is present. Here's a starting point for that. edit In case you really want to do this, git-crypt sounds helpful

Altri suggerimenti

The real answer is that you should not have any sensitive data embedded in your code like this. Connection strings should be read at runtime from some configuration storage (of any like, be in app.config or an INI-file or whatever else), and if you settle on configuration files, you should only keep in the repository samples for these files which are for the reference only.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top