3 ms·
git add -p works quite well from the CLI.
by nitrogen 6y ago
git add -p works quite well from the CLI.
- iudqnolq 6y agoI'm glad it works for you. For me there's a crucial jump in fluency of using something graphical to select lines that makes willing to be more precise. I think a buffer of lines you navigate is just the right metaphor for working with a bunch of text. It's why line editors are generally considered obsolete.
- nitrogen 6y agoSorry, that comment was pre-caffeine and it probably seemed like I was dissing on the GUI. I meant to suggest git add -p as an option for those who don't want to use Magit or similar, or as an intermediate step between git add . and a GUI diffing tool. Git add -p is still pretty useful for reviewing individual changes, but slicing finer than that, or editing patchsets directly as text, is definitely a dark art, but one that I'm glad that I have learned through repeated trial and error (e.g. recognizing that the first column must always be a space, plus, or minus). I would probably have added to my prior comment that a specialized diff editor paired with git add -p might be more useful than doing so with a usual text editor.
- iudqnolq 6y agoNo problem. That all makes sense.
- WorldMaker 6y agoAs a further option, there is also git add -i which is not a great UX and it has its own weird DSL with oddities, but still a slightly "higher level" than git add -p for when people need or want something less fine-grained than git add -p from the command line without installing another git porcelain. git add -i lets you get the status of files in the working directory, add entire files, revert entire files, or patch individual files, all from a single UI "session". You can do all of the same stuff with appropriate pathspecs to the individual commands such as git add -p just/one/file-i-need.md, but git add -i is an option for those that want an "almost GUI" for that.