How to delete latest Git commit in Bitbucket?

I am storing laravel files in bitbucket and I also have a local copy of the project. Every time i save my local copy, i push it to the remote repository in bitbucket so that they have the same update.

Problem: I made a mistake in my local project and I want to delete the latest commit in Remote Repository in bitbucket.

Does anyone know how to remove/delete the latest commit in bitbucket?



you can use git hard reset git reset documentation then you just need to force push your repository

Start by undoing that last commit in your local repository:

If you want to uncommit but keep the changes in the file tree, use

git reset HEAD~1

If you want to completely get rid of the changes, run

git reset --hard HEAD~1

Next, push your repository to bitbucket.

(source and more detail)

git reset --soft HEAD^

First, remove the commit on your local repository. You can do this using git rebase -i. For example, if it's your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up.

Then, force push to your rep by using git push origin +master.

See Git Magic Chapter 5: Lessons of History - And Then Some for more information (i.e. if you want to remove older commits).

please see alternative to git rebase -i

working tree is dirty, you have to do a git stash first, and then a git stash apply after.

Check this post out:

How to move HEAD back to a previous location? (Detached head)

It will describe methods for doing so.

But keep in mind that if your server does not allow force push you will not be able to to push old commit HEAD to the server,

Need Your Help

How to avoid React re-renders when using reselect to compute derived state

reactjs redux immutable.js reselect

I'm using the ultimate combination of React + Redux + Reselect + Immutable.js in my application. I like the idea of reselect because it lets me keep my state (maintained by the reducers) as simple as

Why number of Support vector does not change in SVM?

numpy machine-learning scikit-learn svm

I am a newbe in scikitlearn lib. I am using a SVM bi-class to do pattern classification.