How to delete commits from git on Github and Bitbucket

后端 未结 2 446
挽巷
挽巷 2021-02-02 12:22

I accidentally pushed up files from my .idea directory in my Django project which I had in my .gitignore file. I am trying to completely delete the commit from my bitbucket repo

相关标签:
2条回答
  • 2021-02-02 12:26

    Even if the commits are HARD reset, unwanted commits would still show up in the history. If the history also needs to be reset, then I am afraid only way to do that is to delete and recreate the branch.

    0 讨论(0)
  • 2021-02-02 12:42

    Use git reset --hard 3813803. This can not be undone and works locally as well as remote.

    For remote push using git push --force origin master

    Have a look at the git docu by Atlassian here.

    Let me also quote from there:

    Whereas reverting is designed to safely undo a public commit, git reset is designed to undo local changes. Because of their distinct goals, the two commands are implemented differently: resetting completely removes a changeset, whereas reverting maintains the original changeset and uses a new commit to apply the undo.

    git reset is the one to be used here, though, because you are asking for complete deletion.

    0 讨论(0)
提交回复
热议问题