更好的git add -p? [英] Better git add -p?

查看:922
本文介绍了更好的git add -p?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



现有控制台替代 git添加-p



我喜欢它所做的几乎所有事情(不仅仅是Git GUI),但我讨厌它不允许我查看整个图片并选择我想查看块的顺序。这是Git GUI在 git add -p 给我的唯一实际优势,但它是非常重要的一个。



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



有什么建议吗? p>

解决方案

Vim有一个插件'fugitive'

/ strong>:关联的vimcast(评论)非常好,我推荐它。我想补充一点,通常不需要在longhand中输入:diffget :diffput ,因为你可以在正常/可视模式下通过按 d o d p / p>

这个功能的最佳命令似乎是:Gstatus






Vim是一个终端编辑器(它也碰巧有一个gui端口)



逃亡者插件只会让你编辑索引和worktree版本的文件,让你分散/ diffabtain,直到你满意。 Vim的diff模式比较复杂,比 git add --patch 。更灵活/直观。


  • 滚动链接

  • 语法突出显示和内联(word级别)diff同时突出显示

  • 自动比较折叠>


您可以在这里得到逃亡者



的片段:他逃亡


编辑工作树中的文件并进行一些更改。使用|:Gdiff |打开
索引版本。使用| do |和| dp |在各种各样的克隆带来
同步的文件,或者使用|:Gread |吸纳所有变化。将索引版本写入
阶段。



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?

解决方案

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.

这篇关于更好的git add -p?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆