Search code examples
gitintellij-ideapycharmjetbrains-ide

In a JetBrains IDE, when should you use 'Drop Commit' instead of 'Undo Commit'?


I am looking for some clarification on what Drop Commit does exactly in a JetBrains IDE as I failed to find much documentation on its behavior.

On testing its behavior, I found it to be doing multiple things at once as it also seems to not just remove the commit but also remove the changes in the local repo. Looking for any guidance on this or clarification, thank you.


Solution

  • For every IDE git related command, once you perform it via UI, you can see the input of the command in the Console log in your git window.

    Drop commit does a rebase --interactive --no-autosquash command followed by a hash of a commit made before the commit you are dropping. It interactively rebases your branch on that previous commit and deletes the commit you have selected. This is used to delete the commit entirely and re-write the history.

    Undo commit does a soft reset where all the changes of the commit are staged in your changelist.

    You can read more about git reset here: https://www.w3schools.com/git/git_reset.asp?remote=github

    You can learn more about interactive rebase here: https://www.youtube.com/watch?v=bPX9VHjviEM