使用git diff查看不同文件或者不同commit之间的区别
2022年12月27日 20:20
GitWindowsUbuntuLinuxGitWindowsUbuntuLinux
目录
1. 查看不同文件的区别
a.txt和b.txt不在版本控制系统中:
git diff --color-words --no-index a.txt b.txt
2. 查看不同commit之间的修改
git diff --color-words HEAD~4 HEAD~3
git diff --color-words ac238c26 5d449a61
3. 把diff的转换为html保存
# 首先安装ansi2html
# https://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh
wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O ansi2html.sh
chmod +x ansi2html.sh
git diff --color-words HEAD~4 HEAD~3 | ansi2html.sh > docs/diff.html
然后可以用浏览器打开docs/diff.html查看,打印成pdf文件也可以
4. ansi2html.sh文件内容
#!/bin/sh
# Convert ANSI (terminal) colours and attributes to HTML
# Licence: LGPLv2
# Author:
# http://www.pixelbeat.org/docs/terminal_colours/
# Examples:
# ls -l --color=always | ansi2html.sh > ls.html
# git show --color | ansi2html.sh > last_change.html
# Generally one can use the `script` util to capture full terminal output.
# Changes:
# V0.1, 24 Apr 2008, Initial release
# V0.2, 01 Jan 2009, Phil Harnish <philharnish@gmail.com>
# Support `git diff --color` output by
# matching ANSI codes that specify only
# bold or background colour.
# P@draigBrady.com
# Support `ls --color` output by stripping
# redundant leading 0s from ANSI codes.
# Support `grep --color=always` by stripping
# unhandled ANSI codes (specifically ^[[K).
# V0.3, 20 Mar 2009, http://eexpress.blog.ubuntu.org.cn/
# Remove cat -v usage which mangled non ascii input.
# Cleanup regular expressions used.
# Support other attributes like reverse, ......剩余内容已隐藏
查看完整文章以阅读更多
使用git diff查看不同文件或者不同commit之间的区别
2022年12月27日 20:20
GitWindowsUbuntuLinuxGitWindowsUbuntuLinux
目录
1. 查看不同文件的区别
a.txt和b.txt不在版本控制系统中:
git diff --color-words --no-index a.txt b.txt
2. 查看不同commit之间的修改
git diff --color-words HEAD~4 HEAD~3
git diff --color-words ac238c26 5d449a61
3. 把diff的转换为html保存
# 首先安装ansi2html
# https://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh
wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O ansi2html.sh
chmod +x ansi2html.sh
git diff --color-words HEAD~4 HEAD~3 | ansi2html.sh > docs/diff.html
然后可以用浏览器打开docs/diff.html查看,打印成pdf文件也可以
4. ansi2html.sh文件内容
#!/bin/sh
# Convert ANSI (terminal) colours and attributes to HTML
# Licence: LGPLv2
# Author:
# http://www.pixelbeat.org/docs/terminal_colours/
# Examples:
# ls -l --color=always | ansi2html.sh > ls.html
# git show --color | ansi2html.sh > last_change.html
# Generally one can use the `script` util to capture full terminal output.
# Changes:
# V0.1, 24 Apr 2008, Initial release
# V0.2, 01 Jan 2009, Phil Harnish <philharnish@gmail.com>
# Support `git diff --color` output by
# matching ANSI codes that specify only
# bold or background colour.
# P@draigBrady.com
# Support `ls --color` output by stripping
# redundant leading 0s from ANSI codes.
# Support `grep --color=always` by stripping
# unhandled ANSI codes (specifically ^[[K).
# V0.3, 20 Mar 2009, http://eexpress.blog.ubuntu.org.cn/
# Remove cat -v usage which mangled non ascii input.
# Cleanup regular expressions used.
# Support other attributes like reverse, ......剩余内容已隐藏
查看完整文章以阅读更多