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