Skip to content

thelinuxadmin/skills-change-commit-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Remove commit history

Accidental commits can be tricky to remove with Git. In this GitHub Skills course, you'll use BFG Repo-Cleaner to to change the history of a Git repository. You can apply what you learn in this course to fully remove sensitive material from your own repository.

Step 3: Avoiding future commits with .env

Nice work removing the file from entire history of the repository! ✨

The steps we've taken so far ensure that any new clones of the repository don't contain the sensitive data. But what about collaborators that may already have a copy of the repository? You should ask anyone with a copy of the repository to delete it and clone the repository fresh. In a real-life scenario, you'd also take additional steps to ensure no sensitive data is cached on github.com.

Now that we've mitigated the risk of exposing sensitive content, we'll be proactive and prevent its addition.

We'll now configure Git so it ignores a future addition of sensitive content by adding .env to .gitignore. If someone should that file to the local copy of their repository, it will remain only on the contributor's machine and won't be pushed to GitHub.

What is .gitignore? This special file allows us to tell Git naming patterns to ignore. You can read more about it in Ignoring files on GitHub Docs.

⌨️ Activity: Add .env to .gitignore

  1. Update the local copy of your repository to ensure you have the most recent version of the course files.
    git pull
  2. Locate the file we added to the repository titled .gitignore.
  3. Add .env to the file.
  4. Stage, commit the file:
    git add .gitignore
    git commit -m "ignore .env files"
  5. Push the file to github.com
    git push
  6. Wait about 20 seconds then refresh this page (the one you're following instructions from). GitHub Actions will automatically update to the next step.

Get help: Post in our discussion boardReview the GitHub status page

© 2024 GitHub • Code of ConductMIT License

About

My copy of the skills course on changing commit history

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published