0

I have accidentally committed my credential in my GitHub repo.

I have to delete this credential(AWS_ACCESS_KEY_ID, secret access) from here otherwise my account will be suspended. I have deleted the credential from my account now but it is exposed in the previous commit.

imsaiful
  • 1,556
  • 4
  • 26
  • 49
  • 1
    As long as you have revoken the credentials, you are ok. – hjpotter92 Sep 01 '18 at 10:57
  • Possible duplicate of [Remove sensitive files and their commits from Git history](https://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-commits-from-git-history) – phd Sep 01 '18 at 12:54

1 Answers1

7

You can remove from your git history with two steps. Merge/Edit/remove commit and force push. Details below

  1. Merge those two commits into one

    git rebase -i head~20   //I used 20 based on your repo. Some number greater than your two commits which you want to merge
    

    It will open the interactive screen like belowenter image description here Here change pick to squash to merge the commit with the previous commit. In your case change is at line 6. You can drop/edit commits also

    Then save and quit (:wq) and which will ask for new commit message for the combined commits. Edit, save and quit.

  2. It will show the message like Your branch and 'origin/master' have diverged, and have 15 and 16 different commits each, respectively. (less than 1 for 1 squash)

  3. Do force push git push -f
Dinesh Balasubramanian
  • 20,532
  • 7
  • 64
  • 57