Things I Learned (2022-1)

1 minute read til learning   github   git Comments

For as long as I can remember, I have been a command-line guy. I've always loved the simplicity of being at the command prompt, and I tend to have multiple terminals open at any given time.

Most of my interaction with git is through the command line - cloning, branching, adding files, commiting files, but anytime I had to do more complex things, I'd use a tool like SourceTree. For example, take adding files. Normally, I would do

git add .
to add any changed files. For those times when I only wanted to stage specific changes within a file, I would defer to SourceTree.
A screenshot of SourceTree staging a hunk
Using SourceTree to stage a hunk


I learned how to stage hunks directly from the command line. This is something I'd always use SourceTree for, but I was watching "8 Git Commands You Should Know" on LinkedIn Learning recently and discovered

git add -p
Output from git add dash p
Using git add -p to stage a hunk
I have no idea how I've made it this long without knowing this, but it's now part of my workflow and much less jarring than having to switch context to a UI.

Of course, this led me to

git add --interactive
but that's for another post!