Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git beyond commit - keep your history clean

Yannick Baron
October 18, 2022
97

Git beyond commit - keep your history clean

Mergen Sie noch oder Rebasen Sie schon? In dieser Session schauen wir uns ein
paar Tricks mit git an, mit dem Ziel die git History sauber und lesbar zu halten.
Hier findet vieles Anwendung, was über das übliche Commiten und Pushen in der IDE hinausgeht. Themen wie Interactive Rebase, fixup, autosquash und das Splitten von Hunks finden hier unter anderem seinen Platz.
Je nach Lust und Laune sind auch Abstecher in andere Themen denkbar.

Yannick Baron

October 18, 2022
Tweet

Transcript

  1. Git - beyond commit keep your history clean Yannick Baron

    @yannick_baron Software Architecture Consultant
  2. Clone the repository Make changes Mess things up Look at

    StackOver fl ow and copy an obscure command "Git is easy"
  3. Clone the repository Make changes Mess things up Look at

    StackOver fl ow and copy an obscure command Mess things up even more "Git is easy"
  4. Clone the repository Make changes Mess things up Look at

    StackOver fl ow and copy an obscure command Mess things up even more Delete folder "Git is easy"
  5. Clone the repository Make changes Mess things up Look at

    StackOver fl ow and copy an obscure command Mess things up even more Delete folder Clone the repository ... "Git is easy"
  6. • The git history is a graph, a tree to

    be precise • A node in that tree is the state of our fi les at a point in time • Most operations deal with how to navigate and manipulate that tree The git history
  7. • Understand the evolution of the project (history, communication) •

    Rollback to (or revert / redo) previous change • Find or compare to previously working code • Find which change introduced an error • Understand when development paths divert and see potential con fl ict • ... Uses of the git history
  8. • Understand the evolution of the project (history, communication) •

    Rollback to (or revert / redo) previous change • Find or compare to previously working code • Find which change introduced an error • Understand when development paths divert and see potential con fl ict • ... A clean history keeps things readable, traceable and makes integration of changes easier Uses of the git history
  9. But rebase is evil because force push is evil and

    loses data git push --force-with-lease git push --force-if-includes
  10. git add -p git commit --amend [--no-edit] git commit --fixup

    
 git rebase -i --autosquash Tricks to keep the history clean
  11. • fi xup • squash • reordering • editing past

    commits • rewording • ... Interactive Rebase