A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.