Order of operations for getting code from local to merged into main:

1. Commit early; commit often - write the random useless commit message that makes sense at the time. đź’ˇIf you know it's a temporary commit, add that to the message! I use "squash/drop this commit - {context}"
2. Open a draft PR - Give yourself a todo list and start putting your path up for your team to see. Getting feedback early in your process will reduce your cognitive load when it's time for CR. đź’ˇSeeing code diff in a GUI can help you catch mistakes/optimizations before others
3. Amend commits - forgot to lint and missed a console.log? `git commit --amend --no-edit` is your friend. Just append that change to your previous commit and you're good!đź’ˇI also use this so my colleagues don't notice when I've made a dumb error that I caught myself
4. Rebase often - This is not only to avoid merge commits! This is the biggest reason "it works on my machine" is a meme in swe tech. Things can happen that you might not see and a CI might not catch either. đź’ˇThis reduces your feedback loop on a PR so you catch your own bugs
5. Squash and drop - Rebase your branch using the interactive argument. This allows you to see how you've organized your commits and make small changes (remember when you noted to yourself to squash that commit?) đź’ˇYou can also rewrite commit messages that no longer make sense
6. Reorganize - Reset your branch (after rebasing!!) if your commit structure feels difficult to review. Do your commits accurately reflect what you would do NOW if you had the same context when you started? đź’ˇHelp colleagues review faster by giving them a good commit structure
You can follow @cherthedev.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: