Question

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?

Was it helpful?

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...

OTHER TIPS

And you can use a private GitHub email address for future commits.

GitHub gives a no-reply email address for every user, something like user-name@users.noreply.github.com.

You can enable it by going to https://github.com/settings/emails and toggling on Keep my email addresses private & Block command line pushes that expose my email.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top