Sourcetree - undo unpushed commits

前端 未结 4 1467
一个人的身影
一个人的身影 2020-12-12 09:08

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 co

4条回答
  •  無奈伤痛
    2020-12-12 09:53

    1. Right click on the commit you like to reset to (not the one you like to delete!)
    2. Select "Reset master to this commit"
    3. Select "Soft" reset.

    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.

提交回复
热议问题