3 ms·
A couple of hidden gems: git diff --staged (shows the diff between the last commit and what you've got staged, great when what you're staging is finicky, lets
by nomilk 2y ago
A couple of hidden gems:
git diff --staged (shows the diff between the last commit and what you've got staged, great when what you're staging is finicky, lets you double check that you have precisely the files/hunks you intended)
git log <file> (git log, but for just commits where <file> was touched; saves pilfering through all of git log, especially useful when the file only gets modified infrequently)
Random tip: when using git add --patch, try the 'e' option if you need more nuance than the hunks git provides (it contains instructions for how to ex/include individual lines, so you don't have to remember how to do it).
- omginternets 2y ago15 years… 15 years to discover git diff --staged !
- neoecos 2y agoI don't consider myself a git savvy person, but the help gives output, and I think this command is used a lot
- m0zzie 2y agoWow, TIL `git diff --staged` exists and is an alias to `git diff --cached`, which I have used for many years. "staged" certainly feels more intuitive, but will I ever be able to undo this muscle memory?!
- anbotero 2y agoSame here. Just make it an alias: ds. I’m using git dc, but it seems ds may be my new one, haha.
- Falimonda 2y agoI find aliasing a lot of these saves me a good chunk of time and reduces the barrier to better organize my work. In case anyone cares to browse or suggest their own: https://gitlab.com/Falimonda/gitrc https://gitlab.com/Falimonda/gitrc
- NobodyNada 2y ago> git diff --staged (shows the diff between the last commit and what you've got staged, great when what you're staging is finicky, lets you double check that you have precisely the files/hunks you intended) If you set `git config --global commit.verbose true`, then Git will automatically include this diff in the comment section of the commit message editor.