3 ms·
Try using a tool like 'git cola' that allows you to selectively commit soecific lines, instead of just by file. Start a project and attempt to maintain a clean
by EvanPlaice 11y ago
Try using a tool like 'git cola' that allows you to selectively commit soecific lines, instead of just by file.
Start a project and attempt to maintain a clean history. Break up changes logically into separate commits. To the point where 90%+ don't need more than the subject to describe a change and the history can be read like a story.
Use 'gitk --all' to view the tree of changes. get comfortable with using feature branches, using interactive rebasing to clean up a messy history of changes, etc.
The CLI works great for most things but visual tools make it much easier to write a clean history and reason about the changes over time.
- tuxracer 11y agoYou can also commit specific lines using `git add -p`
- pimlottc 11y agoAdding on to your helpful comment, you can also get a more concise, gitk-like graph of commits with `git log --graph`. This is my standard alias for viewing history, which also adds colors and tag/branch names: lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %C(magenta)(%cn)%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative --left-right
- EvanPlaice 11y agoIt's much easier when you can see all of the staged/unstaged files and drill down to staging/unstaging individual lines within those files. It also highlights whitespace nastiness (ie trailing spaces, missing newline at end of file, inconsistent newline chars, etc). The CLI is the ideal too for a lot of things. Preparing commits is not one of them.
- icebraining 11y agoYou can see all the files and drill down with "git add -i". Git also highlights whitespace problems.
- pimlottc 11y agoI was excited when I first heard about git add iteractive mode but I find the interface to be quite unintuitive and idiosyncratic. I just stick to using "git add -p" to stage hunks selectively in a much more straightforward manner. Having said that, I stage all my commits on command line, and generally go to a GUI rarely for certain visualization tasks.
- brobinson 11y agoI use GitX (forked/updated version) so I can stage/commit line-by-line and see a nice branch/merge visualization: https://rowanj.github.io/gitx/ https://rowanj.github.io/gitx/