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.
Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.
An orphan branch, not surprisingly, has no parents (meaning, git history) when it is created. The history of the orphan branch is separate from other branches in the repository, including the main or root branch it was created from.
As of Git 2.23, you can use git switch --orphan <new branch> to create an empty branch with no history. Unlike git checkout --orphan , all tracked files will be removed.
To create empty branch, you have to go to terminal and execute: git checkout --orphan branchname git rm -rf . Only after that you may see the new branch on GUI. Please, add the feature for creating new empty (without parent) branches on GUI.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With