UC-MACSS / persp-analysis_A18

Perspectives on Computational Analysis (MACS 30000), Autumn 2018
31 stars 49 forks source link

Reverting a commit? #9

Closed smiklin closed 5 years ago

smiklin commented 6 years ago

So, I'm a Contributor 3 and accidentally pushed straight into our master instead of creating a pull request. In the future, if something like this happens, what is the best way to 'undo' a commit?

I googled to find the git revert <SHA> but I'm not really sure how I'd use that? How is it different from a git reset? When is to use one vs another?

jmausolf commented 6 years ago

git reset undos the files you stage to commit, i.e. git add file_A.py but cannot be used to reverse committed changes. Using git status at various stages in the terminal helps illustrate what git reset is doing. On the other hand, git revert is for correcting faulty commits: https://git-scm.com/docs/git-revert

smiklin commented 6 years ago

Thanks!