实时git diff [英] Real-time git diff

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

问题描述

我通常喜欢在查看git diff时输入我的git commit消息。



我非常喜欢可能对我有用,显然这与Linux上的inotify-watch类似。我不需要把它设置在我的OS X开发机器上,但就像我之前提到的那样,通过SSH实现这种功能将是史诗般的。

有没有其他快速和肮脏的UNIXy方法来解决这个问题?

解决方案

您需要像watch git diff之类的东西。 watch命令会重复运行一个命令并显示输出的第一页。



您需要比输出的第一页多,也不想每当它更新的时候都会被移动到输出的顶部 - 您想不断地在diff中查看相同的偏移量,直到您滚动。



我没有尝试过,但是你可能能够使用屏幕或tmux来提供大型虚拟屏幕。 (请参阅 https://serverfault.com/questions/50772/is-there- a-paging-version-of-watch )。

I typically like to type up my git commit messages while looking at the git diff.

I very much enjoy the output produced by this little perl add-on to git, and produces output that looks like this from git diff (this is a screenshot of git log -p but you get the idea:

Because of how it highlights out the corresponding parts of the lines that have changed it is very easy to see what's changed. Just wanted to share that because it does not look like a lot of people use it, and for me it beats the hell out of using an external separate diff tool or something like that, because this works over the terminal! It is also quite more unix-pipe-friendly in general than something like vimdiff though vimdiff is quite handy in a pinch as well.

Anyway, the show-and-tell is only tangentially related to the real question here, which is, can I set up a terminal window where I've got the git diff showing, but to have it be dynamic so that when I save a file it can refresh the git diff for me? Basically the idea is to have a terminal window serve as a real-time display of the exact changes I am about to commit, and this way I can just switch straight from my text editor to entering the git commit command while reading the entire set of changes, and to have this workflow also be a possibility on a Linux machine over SSH as well.

That would be a really awesome workflow, and I think a little bit of cmdline fu can get me there, but I'm not really sure where to start. It seems like OS X and Linux would require separate implementations. I found fswatch which might work for me, and apparently that is similar to inotify-watch on Linux. I shouldn't need to set this up on more than just my OS X dev machine, but like I mentioned before, having this capability over SSH would be epic.

Are there any other quick-and-dirty UNIXy approaches to this problem?

解决方案

You would like something like "watch git diff". The "watch" command repeatedly runs a command and shows the first page of output.

You need more than the first page of output, and also you don't want to be moved to the top of the output whenever it updates - you want to constantly view the same offset in the diff until you scroll.

I haven't tried it but you might be able to use "screen" or "tmux" to provide a large virtual screen. (See https://serverfault.com/questions/50772/is-there-a-paging-version-of-watch.)

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

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