Skip to content

Double checking how to remove .env from repo #126569

Discussion options

You must be logged in to vote

@MitchelliJ

Your plan to remove the .env file from your repository is almost correct, but there's an important detail regarding the visibility of the .env file in the commit history. Simply adding the file to .gitignore and removing it from the staging area will not prevent it from being seen in previous commits. To completely remove the .env file from the commit history, you'll need to use the git filter-repo tool (or git filter-branch for older versions).

  1. Add .gitignore file: Create a .gitignore file and add .env to it.

  2. Remove the .env file from the repository and history:
    If you haven't already installed git filter-repo, you'll need to do that first:
    pip install git-filter-repo

  3. T…

Replies: 2 comments 4 replies

This comment was marked as off-topic.

Comment options

You must be logged in to vote
4 replies
@MitchelliJ
Comment options

@ashutosh7i
Comment options

@geetansh-oss
Comment options

@jakubwawrzyczek
Comment options

Answer selected by MitchelliJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Security Build security into your GitHub workflow with features to keep your codebase secure Question
6 participants