Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 581
Esat IBIS Avatar asked Jan 30 '14 07:01

Esat IBIS


People also ask

How do I hide changes in GitHub?

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.

How do I remove a commit from GitHub?

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.

How do I ignore a commit?

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.

Can you delete commit history in GitHub?

If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history.


1 Answers

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

like image 147
John Avatar answered Oct 29 '22 10:10

John