Make Git repo public without revealing past commits

I have a private repo that had a bunch of sensitive data committed. However, I recently cleaned up all of the sensitive data so that it can be public. If I change a private repo on GitHub to become public, are all past commits visible (i.e. could someone see that sensitive data from the past)?

If so, how do I make the repo public without making the past commit history public?

  • Highly coupled git submodules
  • Force git custom merge driver for the purpose of merging pom.xml (maven) files
  • Do I need two GitHub accounts for this?
  • Git subtree tags
  • Heroku push rejected, Could not communicate with vendor, please try again later
  • git merge --no-commit vs git cherry-pick --no-commit
  • Limit depth of .gitignore
  • Git: Show content of file as it will look like after committing
  • Git - Use port 9418 for remote on github
  • Assign a remote for Git Push
  • Putting existing project under source control in Xcode 4.3.2
  • git - trim whitespace
  • 2 Solutions collect form web for “Make Git repo public without revealing past commits”

    Go to desired commit:

    git checkout <your_commit_hash>
    

    Go down to the initial commit leaving all current changes:

    git reset <intial_commit_hash_here> --soft
    

    Then commit with amend option

    git commit --ammend -m'My new initial commit'
    

    And then you are ready to push to your public repo

    git push <your_remote> master
    

    P.S.
    change history will still be available with git reflog but will not be pushed to remote repo

    I’d recommend cloning (or just copying all the non .git files) from the current repo into a new repo and then pushing the new repo out as public.

    Git Baby is a git and github fan, let's start git clone.