Add daily email for 2024-05-06
Interactive staging
This commit is contained in:
parent
3a5f60be83
commit
44ae1e91a1
50
source/_daily_emails/2024-05-06.md
Normal file
50
source/_daily_emails/2024-05-06.md
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
---
|
||||||
|
title: Interactive staging
|
||||||
|
date: 2024-05-06
|
||||||
|
permalink: archive/2024/05/06/interactive-staging
|
||||||
|
tags:
|
||||||
|
- software-development
|
||||||
|
- git
|
||||||
|
cta: ~
|
||||||
|
snippet: |
|
||||||
|
TODO
|
||||||
|
---
|
||||||
|
|
||||||
|
A major addition to my Git workflow has been the ability to interactively add hunks of code to be committed.
|
||||||
|
|
||||||
|
There's `git add -i` to interactively add, though I usually go straight to `git add -p` to use `patch`.
|
||||||
|
|
||||||
|
This will ask you to confirm if you want to add each hunk to the commit (a.k.a. the staging area) or not.
|
||||||
|
|
||||||
|
For example, here's the prompt I get whilst working on the post for this email:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
diff --git a/source/_daily_emails/2024-05-06.md b/source/_daily_emails/2024-05-06.md
|
||||||
|
index 42fe48f..ef36a2b 100644
|
||||||
|
--- a/source/_daily_emails/2024-05-06.md
|
||||||
|
+++ b/source/_daily_emails/2024-05-06.md
|
||||||
|
@@ -4,10 +4,12 @@ date: 2024-05-06
|
||||||
|
permalink: archive/2024/05/06/interactive-staging
|
||||||
|
tags:
|
||||||
|
- software-development
|
||||||
|
- # - drupal
|
||||||
|
- # - php
|
||||||
|
- # - podcast
|
||||||
|
+ - git
|
||||||
|
cta: ~
|
||||||
|
snippet: |
|
||||||
|
TODO
|
||||||
|
---
|
||||||
|
+
|
||||||
|
+A major addition to my Git workflow has been the ability to interactively add hunks of code to be committed.
|
||||||
|
+
|
||||||
|
+There's `git add -i` to interactively add, though I usually go straight to `git add -p` to use `patch`.
|
||||||
|
+There's `git add -i` to interactively add, though I usually go straight to `git add -p` to use `patch`.
|
||||||
|
(1/1) Stage this hunk [y,n,q,a,d,s,e,?]?
|
||||||
|
```
|
||||||
|
|
||||||
|
I can add the whole hunk, split it into smaller hunks, add all the hunks in the file or ignore this hunk and later hunks in the file.
|
||||||
|
|
||||||
|
Then the process is repeated for any following hunks.
|
||||||
|
|
||||||
|
This means I can add the relevant hunks to craft the commit I want and I can keep my commits small and meaningful, and easy to revert if there is an issue.
|
Loading…
Reference in a new issue