I have been playing around with git (still very noob) and I wanted to know the difference between \"reset\" and \"rebase\". Is the one more powerful than the other?
Say
I hope this layman explanation is correct.
Both git reset and git rebase will affect your local branch. They will force your local branch to be in sync with a certain commit. The difference is that:
Additional Info
When to use reset?
Let's say you finish your work and commit locally. Then your cat walk across the keyboard, and somehow you carelessly commit your cat's work. Use reset.
When to use rebase?
Let's say you refactor the name of a function/class and this change affect many files. When you commit and try to push to origin, you realized your colleague has make some important changes and already pushed it to origin. Let's say you think refactoring the name again (using an IDE) is easier than going through all the conflict files, you can choose to rebase which will erase your work and keep your colleague's one untouched.
Why is every answer/tutorial contains so much technical disclaimer?
Because both reset and rebase can delete local changes forever. So users will need to know how to employ strategies (e.g. create a backup branch) to keep their work.