Search code examples
gitmercurialbazaargit-remote

How do I hide a file from a single remote repo in git?


I've got a project I'd like to start sharing on github which I'd set up as another remote repo. But I've got some sensitive configuration information (amazon s3 account details) that I don't want to obviously share on github.

Is there a way I can get the remote github repos to ignore the settings file, but have the local and other remote repos work with it?

EDIT - reopening this question to see if there are any other distributed source control systems (mercurial? bazaar? etc) that can do this?


Solution

  • Mercurial works the same as Git and you've already gotten good recommendations for that. However, you can setup an encode filter that will remove the password from the file in the repository.

    The idea is that you version a file with

    username =
    password =
    

    but have a file with filled in values locally. Mercurial will ignore the values when you run hg status and hg diff since it shows the results after encoding — the encode filter strips the sensitive information.

    Something like

    [encode]
    settings.cfg = sed "s/(username|password) = .*/\1 =/"
    

    should work. (I cannot test it right now, I'm in a tram.)

    Simply not versioning the file is still the simple, normal, and recommended way to deal with this problem.