Video in progress

Senior 🌿 Git

You want to release an internal library as open source on GitHub. Do you publish it with the current Git history, and what do you check first?

The history may contain old secrets, internal host names, customer data and employees' personal emails. I check the whole history with secret scanners, and if it is not clean, I open a new repo with a single initial commit with no history, and the internal history stays in the private repo.

📖 Answer

Looking over the current code is not enough. An application-prod.yml that was committed in 2021 and deleted later is still in the history, and in a public repo anyone can find it with git log -p.

What I check:

# secrets: across all branches and tags
gitleaks detect --source . --log-opts="--all"
trufflehog git file://. --only-verified

# internal addresses and names
git log -p --all | grep -nE 'internal\.shop\.uz|10\.[0-9]+\.[0-9]+\.[0-9]+' | head

# who has committed
git log --all --format='%an <%ae>' | sort -u

Also:

  • real customer data in test resources (dumps, CSVs, log samples);
  • code ownership and licensing: files copied from another project, code written by a contractor;
  • internal ticket links and customer names in commit messages;
  • big binaries and unneeded branches, old tags.

Even if a secret you found gets cleaned out of the history, it is rotated, because it has sat in many clones for years.

The decision: if the history is clean and valuable, I clean out the unneeded paths and emails with git filter-repo (--mailmap), scan again, and publish. Often, though, a simpler and safer option is:

git switch --orphan public-main
git commit -m "Initial public release"

The public repo starts from that commit, and further work continues in the open.