How to delete a commit?

I'm using the Bitbucket (Git) with Netbeans. For some reason, a commit included a folder (build folder that contains binaries files, such as .class and .jar files) that was marked to be ignored. Now, I'm trying to delete the commit from repository and redo the commit.

2 answers

This widget could not be displayed.
Jason Worley Atlassian Team Jul 30, 2013

You can look into the git revert command. More info available here:

https://www.atlassian.com/git/tutorial/undoing-changes#!revert

This widget could not be displayed.

If the commit has not yet been pushed, you can use `git reset` to reset the branch to the commit before the bad commit. Beware that this changes git history and you will lose the commit(s) on the branch that occurred after the commit to which you reset the branch to.  

Note: If the commit has already been pushed, you can still technically use `git reset`, but you will then have to use `--force` when pushing, which will overwrite git history on your remote git repository. Overwriting git history can be acceptable in some cases, but it is not a good idea in many cases, such as if other developers have checked out the same branch.
Also: remote repositories can be configured to prevent history re-writing, in which case you should not use `git reset` to remove pushed commits. 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 10, 2018 in Bitbucket

What is your #1 piece of advice to new users getting started using Bitbucket?

Hello Community! My name is Claire Maynard, and I’m a Product Marketing Manager on the Bitbucket team. I’m interested in hearing what advice or tips you have for new users getting started on ...

249 views 14 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you