Search code examples
gitrstudiogit-checkoutgit-resetgit-revert

RStudio revert button seems to act like Git reset


I am quite new to RStudio and Git, so I would like to make sure that I understand correctly what I am doing.

The Git documentation says that git revert creates a new commit. When I press the RStudio revert button, no new commit is created, it just goes back to the last commit. To me this seems to be a git reset --hard. Did I get anything wrong?


Solution

  • RStudio Revert functionality differs from git reset functionality.

    According to this manual git reset --hard do this

    Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.

    So your full project will return to previous commit state

    But according to this RStudio Revert Changes popup window:
    only selected file will be changed to previous commit state.

    enter image description here

    And this can be done with git combination of

    • git reset file (Unstage a file)
    • git checkout file (Discard changes in the working directory)

    See more about resetting, checking and reverting here