I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.
Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.
I could also delete my local repository and pull it again without my local commit, but maybe there's another way?
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.