Search code examples
version-controldatasourceatlassian-sourcetree

SourceTree - How to undo Pushed commits


Using Source Tree 1.9, there are 5 commits e.g. a-b-c-d-e that are pushed to develop branch and I want to undo pushed commits for "c".

  1. will that affect other commits - a,b,d,e.
  2. How to undo commit done for "c" without affecting other commits.

Solution

  • You cannot undo a pushed commit.

    But you can use the reverse commit functionality (right click on the commit and select Reverse Commit). This feature adds another commit on top which is the reverse of the one you selected.

    For example:

    • If you added a line of code, this removes it
    • If you created a file, this deletes it
    • If you deleted a file, this restores it