git branch without history

branch, git

Solution

One thing you could do is create a branch of your repo, edit out the passwords, and then create a shallow clone (with depth 1) of that repository that you would give to the partners. They can make patches and whatnot against that clone, but can't see the whole history and can't push the repo anywhere else. If they're just making changes, then this should be a workable solution. You can still accept patches from them and apply to your master repository.

See the `--depth` option of `git clone` for further information.

Problem

My git repo contains sensitive passwords which, for reasons out of my control, can't be removed right now. Right now it's all OK because this repo is internal-only, but I've been asked to create a branch that's safe to share with partners. Is there any way to create a branch in git and then remove files from it in a way where they can't be retrieved using the log? Seems like a long shot, but thought I'd ask. The only solution I can think of is to copy the file tree to a new git repo without the sensitive file--but then I'd lose the ability to merge partner changes back to my repo.

Original source