1

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.

2

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.