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?
GitHub. You can hide whitespace changes for GitHub diffs in two ways. First, click the gear icon near the top of the page and check the “Hide whitespace changes” option.
To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With