Search code examples
githubgit-commitgithub-for-windows

How Can I hide a commit in GITHUB


I posted some code in github but accidentally posted some passwords too and I changed them but it still seen in the commit section.

How could I hide that commit?


Solution

  • The only way to purge that diff is with a force push. If multiple people are working on that same branch, you'd best let them know that you're rewriting history.

    Assuming it was your last commit...

    git reset --soft HEAD~
    (undo password changes)
    git diff
    (make sure there are no changes that display the passwords)
    (stage/commit changes)
    git push origin +branch_name
    

    Following standard security precautions, I would also reset those passwords if they're linked to sensitive data...