|
7 | 7 |
|
8 | 8 | ## Step 2: Removing a file from Git history using BFG Repo-Cleaner |
9 | 9 |
|
10 | | -_You did TBD-step-1-name! :tada:_ |
| 10 | +_You removed `.env` from the repository's root directory! :tada:_ |
11 | 11 |
|
12 | 12 | 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. |
13 | 13 |
|
| 14 | +**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. |
| 15 | + |
14 | 16 | 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). |
15 | 17 |
|
16 | | -**What is _TBD-term-2_**: TBD-definition-2 |
| 18 | +**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. |
17 | 19 |
|
18 | 20 | ### :keyboard: Activity: Use BFG Repo-Cleaner to remove the `.env` file |
19 | 21 |
|
20 | 22 | 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. |
21 | | -2. Run each of the following commands to confirm the state of the repository: |
22 | | - |
| 23 | +2. Confirm the `.env` file is removed from the root directory. THe command should return empty. |
23 | 24 | ```shell |
24 | | - # Confirm .env is removed |
25 | | - # Expected return: empty |
26 | 25 | find . -name ".env" |
27 | | - |
28 | | - # Search for .env in the repository's history |
29 | | - # Expected return: 2 commits from adding and then removing .env |
| 26 | + ``` |
| 27 | +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`. |
| 28 | + ```shell |
30 | 29 | git log --stat --all -- .env |
31 | 30 | ``` |
32 | | - |
33 | | -3. Run the following command to delete all references to `.env` that exist in the repository. |
| 31 | +4. Use BFG Repo-Cleaner to delete all references to `.env` that exist in the repository. |
34 | 32 | ```shell |
35 | 33 | bfg --delete-files .env |
36 | 34 | ``` |
37 | | -4. The tool will run and make some suggestions about some follow-up commands. Run those to get your local repository cleaned up. |
38 | | -5. Push your changes to GitHub. Note we're using the `--force` argument in this step since we're altering Git history. |
| 35 | +5. The tool will run and make some suggestions about some follow-up commands. Run those to get your local repository cleaned up. |
| 36 | +6. Push your changes to GitHub. Note we're using the `--force` argument in this step since we're altering Git history. |
39 | 37 | ```shell |
40 | 38 | git push --force |
41 | 39 | ``` |
42 | | -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. |
| 40 | +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 commit comments