Rewriting history in Git
Published 2017-09-20, 21:00
Once again I was confused about rewriting history in Git:
Why and how is "rebase" and "rewrite history" in git the same thing? I'm confused. A lot.
— Jan Piotrowski (@Sujan) September 20, 2017
As I am not a git power user – I use a GUI, SourceTree of GitKraken – for the more complicated commands and features, my mind tends to just „crash“ now and then and forget what they are and how they work.
A bit later I had it figured out again:
Answer myself: Rebase "reapplies" commits by creating "copies" of them. These "copies" can be modified. Rebasing on same "base" = rewrite.
— Jan Piotrowski (@Sujan) September 20, 2017
During these 15 minutes I googled around and found some nice explanations I now want to conserve for future reference:
- Git Interactive Rebase, Squash, Amend and Other Ways of Rewriting History
- Reword the last commit message
- Reword other commit messages
- Interactive Rebase
- Reword other commit messages, take 2
- Squash commits together
- Rebase on top of master
- DANGER: You are rewriting history
- Rewriting History with Git Reset
- soft reset
- mixed reset
- hard reset
- Changing history, or How to Git pretty: Lesson three: How to change history
- revert
- –amend
- reset
- rebase
And an additional nice thing to know and use when playing around with those:
- Git Tutorial: How to Never Lose Changes in Git
- Create an additional branch to secure your commits
Zum Artikel Rewriting history in Git sind noch keine Kommentare vorhanden. Deine Meinung wäre jedoch willkommen!