Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

What you need is not to make additional commits, but to modify the commits you made.

Solution 1 (easy): Remove commits and close the PR

  1. keep the PR open and do not delete the branch

  2. create a local back up branch in case you want to cherry-pick commits later on

  3. switch to the branch of the PR that has the sensitive data

  4. make a commit to delete the sensitive data if you have not

...

Expand
titleDemo

Situation: We have a PR that has two commits. The first commit has sensitive data.

  1. make a commit to remove the sensitive data

  2. push the branch

  3. hard-reset to the commit before adding the sensitive data

  4. force-push

    Screen Recording 2023-08-09 at 1.31.36 PM.mov

Solution 2 (advanced): Rewrite commits and keep the PR

  1. create a local back up branch in case the branch is messed up

  2. switch to the branch of the PR that has the sensitive data

  3. make a commit to delete the sensitive data if you have not and push the branch (this is for the sensitive data not to show on GitHub after force-pushing)

  4. rewrite commit history using git rebase -i
    (https://docs.github.com/en/get-started/using-git/using-git-rebase-on-the-command-line)

  5. force-push

...