TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: `Git add -p` with multiple buckets

94 点作者 aleclm大约 3 年前

14 条评论

mushyhammer大约 3 年前
I find it crazy how many people like working with git from the command line and just use -a any chance they get.<p>I never commit from CLI and have been using GitHub Desktop for years (it works on any repo&#x2F;remote). Selecting individual files, patches, or even lines is a breeze. I usually make a bunch of changes, then pick, commit, branch, repeat. Every branch is based off `main` and can be pushed independently. Any leftover will just be dropped (any logging&#x2F;testing lines that I never picked, for example)<p>Using a UI makes it easy to review your changes before you commit them, there’s no way you can review (and pick or discard) your 100-lines 5-files changes effectively on the command line.<p>GitHub Desktop is quite limited and I hope it stays that way, I still use the cli for operations other than commit and checkout.
评论 #30741013 未加载
评论 #30739807 未加载
评论 #30740802 未加载
评论 #30740553 未加载
评论 #30740674 未加载
u801e大约 3 年前
There&#x27;s a set of utilities[1] in a package called patchutils that contains several commands to manipulate patches. Their version of splitdiff[2] will create a set of patch files from a single patch where each patch would only apply to a single file. It doesn&#x27;t appear to have the capability of splitting out individual hunks like your version, but could be updated to do so.<p>[1] <a href="https:&#x2F;&#x2F;directory.fsf.org&#x2F;wiki&#x2F;Patchutils" rel="nofollow">https:&#x2F;&#x2F;directory.fsf.org&#x2F;wiki&#x2F;Patchutils</a><p>[2] <a href="https:&#x2F;&#x2F;www.unix.com&#x2F;man-page&#x2F;suse&#x2F;1&#x2F;splitdiff&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.unix.com&#x2F;man-page&#x2F;suse&#x2F;1&#x2F;splitdiff&#x2F;</a>
jayd16大约 3 年前
This is the one P4 workflow feature I wish git had from the beginning. In Perforce, changes can be grouped into uncommitted &quot;change lists.&quot; Its really helpful if you&#x27;re working on multiple things especially when they&#x27;re unrelated features or projects. Works very well for artists and such.<p>Sadly P4 fumbles at the 10 because you can&#x27;t split changes by hunk, file only.<p>I hope something like this (or maybe just multiple named stages?) makes it into git.
评论 #30739789 未加载
评论 #30739056 未加载
评论 #30740747 未加载
dorianmariefr大约 3 年前
I feel like this should be part of git, also naming it git-split-patch and having it in the PATH would allow to to do `git split-patch`
评论 #30739124 未加载
评论 #30737821 未加载
almog大约 3 年前
Is the main use case being splitting large uncommitted change set into logical units in _one pass_ rather than few iterations of `git add -p &amp;&amp; git commit`?
评论 #30739415 未加载
评论 #30741119 未加载
评论 #30739215 未加载
westurner大约 3 年前
There are probably a couple good ways to avoid trying to split `git add -p` with e.g. jujutsu `jj`? <a href="https:&#x2F;&#x2F;github.com&#x2F;martinvonz&#x2F;jj&#x2F;blob&#x2F;main&#x2F;docs&#x2F;git-comparison.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;martinvonz&#x2F;jj&#x2F;blob&#x2F;main&#x2F;docs&#x2F;git-comparis...</a><p>If CI isn&#x27;t running tests for every PR, `git add -p` can create pretty patches that fail when attempting to `git bisect` later.<p>&gt; <i>Comprehensive support for rewriting history: Besides the usual rebase command, there&#x27;s `jj describe` for editing the description (commit message) of an arbitrary commit. There&#x27;s also `jj edit`, which lets you edit the changes in a commit without checking it out. To split a commit into two, use `jj split`. You can even move part of the changes in a commit to any other commit using `jj move`.</i>
abalaji大约 3 年前
This is great, I&#x27;ve been using Sublime Merge similarly in my workflow. I stage individual files while drafting the commit message and make sure to split lines across commits for logical rollbacks. I personally find it a lot faster than using the CLI, at least in this case.
评论 #30739762 未加载
评论 #30737610 未加载
fuzzy2大约 3 年前
Ah, finally changelists are coming to Git. Having worked with Perforce, this certainly feels very familiar.
评论 #30738495 未加载
ArtRichards大约 3 年前
I was looking a few years ago for a GUI for git, on linux. I eventually settled on SmartGit, been using it since..<p><a href="https:&#x2F;&#x2F;www.syntevo.com&#x2F;smartgit&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.syntevo.com&#x2F;smartgit&#x2F;</a><p>Anyone have alternatives for Linux?
评论 #30741084 未加载
评论 #30741122 未加载
renewiltord大约 3 年前
Oh this is interesting. Sometimes I make unrelated changes and then I want to tease the things apart at commit time. And when I do I find that I don’t just want to stage or skip staging. Worth a shot but I’d prefer if I could put it into secondary staging and post-commit the first of those becomes staged.<p>Probably doable and shiftable to a git-splitpatch too.
评论 #30737349 未加载
评论 #30737151 未加载
pabs3大约 3 年前
I generally just use `git gui` to make multiple commits by staging and then committing just the lines I want.
评论 #30749106 未加载
alfiedotwtf大约 3 年前
Oh very nice! This almost seems obvious that it should be part of git itself!
kasabali大约 3 年前
See also Mercurial Queues (<a href="https:&#x2F;&#x2F;www.mercurial-scm.org&#x2F;wiki&#x2F;MqExtension" rel="nofollow">https:&#x2F;&#x2F;www.mercurial-scm.org&#x2F;wiki&#x2F;MqExtension</a>)
junon大约 3 年前
I wish git supported this directly. Even if it was specific functionality to `git commit -p`.