Open github-learning-lab[bot] opened 4 years ago
848cd8c2043f6161a4f0043bffee212777281494
Nice, that's the commit that added the .env
file. We'll need to remove the contents of this commit, as well as the commit that removed it from the history.
.env
fileWe can do this with the following commands:
Since we cloned the repository earlier, let's run git checkout master
to put us back on the master branch
Run git pull
to update your local repository with the changes we merged from the contributor's pull request
Run git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD
to remove the historical reference to the .env
file
Note: There is a lot going on with this command. We won't be diving into everything this command is doing, but it's filtering through the master branch and removing any cached reference to a .env
file.
Next, let's run git push -f
to force push this change to the master branch
Let's now run git log --oneline
to get a list of our modified commit history
Paste your log output into this issue as a comment
40be5a9 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #9 from richross/add-gitignore e4b0d45 Update gitignore 0c3879a Merge add-wolverine-image into master a92fd80 Add wolverine image to game e0894cf Merge pull request #7 from richross/richross-patch-2 f34073c Create Security.md 25ca5a2 Merge pull request #1 from richross/update-dependency e98641b update dependency e9ae69a Change package.json file to highlight where dependency update should go 831b1d1 Add empty .gitignore file 78cfef0 Remove .env file 8f08f15 Add .env file e6e2377 Update README.md and Octocat game 528248c Initial commit
40be5a9 (HEAD -> master, origin/master, origin/HEAD) #9 from richross/add-gitignore e4b0d45 Update gitignore 0c3879a Merge add-wolverine-image into master a92fd80 Add wolverine image to game e0894cf Merge pull request #7 from richross/richross-patch-2 f34073c Create Security.md 25ca5a2 Merge pull request #1 from richross/update-dependency e98641b update dependency e9ae69a Change package.json file to highlight where dependency update should go 831b1d1 Add empty .gitignore file 78cfef0 Remove .env file 8f08f15 Add .env file e6e2377 Update README.md and Octocat game 528248c Initial commit
Sensitive data elsewhere in the repository contents
Often sensitive data is buried deep in a repository's history. The process for removing these files and commit data is a bit tricker and more involved.
In our repository's history, there is a reference to a
.env
file with sensitive information. We've since added a.gitignore
to prevent this from happening in the future, but it doesn't modify any previously committed references from the history.There are a few things we need to think about and take into consideration before we start altering our historical content. But for now, let's start with identifying the commit in question by going through our commit history.
Step 12: Find historical reference to a previous
.env
filecommits
link directly under the Code tab.env
fileI'll respond below when you add your comment to this issue.