Skip to content

Commit

Permalink
add content for step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorsector committed Jan 18, 2024
1 parent ef9e7d2 commit 5175596
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions .github/steps/2-tbd.md → .github/steps/2-remove-file-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,34 @@

## Step 2: Removing a file from Git history using BFG Repo-Cleaner

_You did TBD-step-1-name! :tada:_
_You removed `.env` from the repository's root directory! :tada:_

Now that we've deleted the file, people that browse the repository on GitHub.com or anyone looking at just the head commit won't see the file. However, due to Git's nature, the file is still present in the history. In this step, we'll work on removing the file from the repository history.

**What is a _head commit_**?: In Git, HEAD points to a branch or a commit. When we say [head commit](https://docs.github.com/en/get-started/quickstart/github-glossary#head), we usually mean the most recent commit in the repository's history.

There are multiple tools available for removing Git history, we'll use BFG Repo-Cleaner in this step. You can find additional documentation on [Using the BFG in GitHub Docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository#using-the-bfg).

**What is _TBD-term-2_**: TBD-definition-2
**What is _BFG Repo-Cleaner_**?: BFG Repo-Cleaner is software that can help you search through and alter repository history. Git can natively do this using [`git filter-repo`](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository#using-git-filter-repo), but it can be more complex.

### :keyboard: Activity: Use BFG Repo-Cleaner to remove the `.env` file

1. Install BFG Repo-Cleaner on your machine. You can follow the [instructions on the web site](https://rtyley.github.io/bfg-repo-cleaner/) to do so or you can use a package manager for your operating system.
2. Run each of the following commands to confirm the state of the repository:

2. Confirm the `.env` file is removed from the root directory. THe command should return empty.
```shell
# Confirm .env is removed
# Expected return: empty
find . -name ".env"

# Search for .env in the repository's history
# Expected return: 2 commits from adding and then removing .env
```
3. Search for .env in the repository's history. The command should return at least 2 commits: the addition of `.env` when you copied this template repository, and the removal of `.env`.
```shell
git log --stat --all -- .env
```

3. Run the following command to delete all references to `.env` that exist in the repository.
4. Use BFG Repo-Cleaner to delete all references to `.env` that exist in the repository.
```shell
bfg --delete-files .env
```
4. The tool will run and make some suggestions about some follow-up commands. Run those to get your local repository cleaned up.
5. Push your changes to GitHub. Note we're using the `--force` argument in this step since we're altering Git history.
5. The tool will run and make some suggestions about some follow-up commands. Run those to get your local repository cleaned up.
6. Push your changes to GitHub. Note we're using the `--force` argument in this step since we're altering Git history.
```shell
git push --force
```
6. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
7. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

0 comments on commit 5175596

Please sign in to comment.