Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting Sensitive Data After Push

Tags:

git

So I am working on a project and add a gitignore file to prevent some sensitive data from being included only it fails to work as expected and now I have pushed it. Is there a way to delete that from the remote repository so there is no evidence of it in the history?

like image 265
ChiliYago Avatar asked Apr 28 '26 19:04

ChiliYago


1 Answers

You could revert the changes locally

git commit --amend

or

git reset <last-hash>

and then do a

git push -f

but this should only be done

if you:

  1. (know what your doing ;-) )
  2. noone else did something with the repo in the meantime

Tip:

Be very careful, that the repository is in the state you want it to be, before you push -f, because changing history is generally a big no-no for various good reasons

like image 50
Stephan Avatar answered Apr 30 '26 22:04

Stephan