更好的 git add -p 吗?

发布于 2024-11-04 14:27:18 字数 259 浏览 1 评论 0原文

有时我在没有安装 X Window 的系统上工作,并且无法使用 Git GUI。

现有的控制台替代 git add -p 的方法是什么?

我几乎喜欢它所做的一切(实际上比 Git GUI 更喜欢),但我讨厌它不允许我查看整个图片并选择我想要查看块的顺序。对我来说,这是 Git GUI 相对于 git add -p 的唯一实际优势,但这是相当重要的。

我尝试了 tig,但我不喜欢它提供的用户体验。

有什么建议吗?

Sometimes I work on system without X Window installed, and can't use Git GUI.

What are existing console alternatives to the git add -p?

I like almost everything that it does (more than Git GUI actually), but I hate that it does not let me view the whole picture and choose the order that I want to review the chunks. That's the only actual advantage of Git GUI over git add -p to me, but it is rather crucial one.

I tried tig, but I do not like the user experience that it offers.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

当梦初醒 2024-11-11 14:27:35

如果我和你处于同样的情况(混合了一些帅哥,其中一些帅哥比其他帅哥“更重要”),我会将较小的帅哥提交到他们自己的提交中,并使用易于区分的提交消息,并只留下那些“更重要”的帅哥,这样他们就不会妨碍差异或 git add -i。

通过为“特权较低”的人提供易于区分的提交消息,以后处理它们应该很容易。

If I were in the same situation as you (a mix of hunks where some hunks are 'more important' than others), I'd commit the lesser hunks into their own commits with easily distinguishable commit message and leave only those 'more important' hunks so that they don't get in the way of diffs, or git add -i.

With the easily distinguishable commit messages for the "less privileged" hunks it should be easy to deal with them later.

囍笑 2024-11-11 14:27:33

是否可以简单地

git diff

“查看全貌”,然后

git add -i
5

选择要提交的第一个文件,暂存大块,然后对下一个文件重复该过程?

what about a simple

git diff

to "view the whole picture" and then a

git add -i
5

to chose the first file you want to commit, stage the hunks, and then repeat the process with the next files?

对你而言 2024-11-11 14:27:31

Vim 有一个插件“fugitive”

编辑链接的 vimcast(评论) 非常棒,我推荐它。我想添加提示,通常不需要手动输入 :diffget:diffput ,因为您可以直接在正常/视觉中执行相同的操作通过按下 dodp 模式。

此功能的最佳开始命令似乎是 :Gstatus


Vim 是一个终端编辑器(恰好也有一个 gui 端口)。

逃亡插件将简单地让您编辑索引和工作树版本文件彼此并排,让您 diffput/diffobtain 直到您满意为止。 Vim 的 diff 模式非常复杂,并且比 git add --patch 更加灵活/直观。

  • 滚动绑定
  • 语法突出显示和行内(字级)差异突出显示同时
  • 自动差异折叠(未更改区域)

您可以 在这里获取逃犯

来自的片段:他逃犯

编辑工作树中的文件并进行一些更改。使用 |:Gdiff|开放
索引版本。使用 |do|和|dp|找各种帅哥把文件带进来
同步,或使用 |:Gread|拉入所有更改。将索引版本写入
暂存文件。

Vim has a plugin 'fugitive'

Edit: the linked vimcast (comments) is excellent and I recommend it. I would like to add the hint that there will normally not be a need to type :diffget and :diffput in longhand, because you can do he same directly in normal/visual mode by pression do and dp.

The best command to start with for this feature appears to be :Gstatus


Vim is a terminal editor (which so happens to have a gui port too)

The fugitive plugin will simply let you edit the index and worktree versions of files alongside each other and let you diffput/diffobtain until you're satisfied. Vim's diff mode is sophisticated, and much more flexible/intuitive than git add --patch.

  • scrollbinding
  • syntax highlighting and intra-line (wordlevel) diff highlighting simultaneously
  • automatic diff folding (of unchanged regions)

You can get fugitive here

Snippet from :he fugitive:

Edit a file in the work tree and make some changes. Use |:Gdiff| to open up
the indexed version. Use |do| and |dp| on various hunks to bring the files in
sync, or use |:Gread| to pull in all changes. Write the indexed version to
stage the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文