From e7f55d2711f45a695c1f65ca90c9d8cbae9309f6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 18 Nov 2024 01:30:54 +0000 Subject: [PATCH] Add daily email for 2024-11-14 Starting with a clean slate --- source/_daily_emails/2024-11-14.md | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 source/_daily_emails/2024-11-14.md diff --git a/source/_daily_emails/2024-11-14.md b/source/_daily_emails/2024-11-14.md new file mode 100644 index 00000000..8e3cce09 --- /dev/null +++ b/source/_daily_emails/2024-11-14.md @@ -0,0 +1,31 @@ +--- +title: Starting with a clean slate +date: 2024-11-14 +permalink: daily/2024/11/14/starting-with-a-clean-slate +tags: + - software-development + - git +cta: ~ +snippet: | + Whenever I need to start a new task, I always try to start with a clean slate. +--- + +Whenever you need to start a new task in a codebase, I think it's important to always try to start with a clean slate. + +This is having an empty staging area and no lingering or uncommitted changes from previous tasks. + +I do this to avoid having contaminated commits that contain multiple changes. Each commit should be related to one change. + +You can use `git add -p` to [review, stage and commit parts of your changes][1], but as the uncommitted changes grow, you're less likely to do that and more likely to commit them at once with a generic commit message that offers no value when viewed in the commit log. + +You're more likely to create better and more valuable commits and write better commit messages if you break them into chunks and commit the changes as you make them. + +If you have extra files you don't want to commit, add them to a `.gitignore` file or `.git/info/exclude` so they're ignored. + +If you have uncommitted changes that you want to hide for now but re-add later, [git stash is your friend][0]. + +If you want your changes to be completely separate, maybe [git worktrees are for you][2]. + +[0]: {{site.url}}/daily/2024/10/24/git-stash-is-underrated +[1]: {{site.url}}/daily/2024/10/25/always-review-your-changes +[2]: {{site.url}}/daily/2022/08/12/git-worktrees-docker-compose