阅读 92

git比较不同文件的差异

之前听别人说git只能通过commit的hashID来比较文件,事实上,在当前工作区也可以直接比较:

git diff 文件A路径 文件B路径
复制代码

会显示如下的结果:

diff --git a/gdb/configure-origin.ac b/gdb/configure.ac
index 0805827..a8008dd 100644
--- a/gdb/configure-origin.ac
+++ b/gdb/configure.ac
@@ -834,29 +834,31 @@ else
    esac
  esac

+  python_config=
  if test "${python_prog}" != missing; then
+    AC_CHECK_TOOL(python_config,[${python_prog}-config],[${python_prog} ${srcdir}/python/python-config.py])
    # We have a python program to use, but it may be too old.
    # Don't flag an error for --with-python=auto (the default).
    have_python_config=yes
-    python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes`
+    python_includes=`${python_config} --includes`
    if test $? != 0; then
      have_python_config=failed
      if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --includes)
+        AC_ERROR(failure running ${python-config} --includes)
      fi
    fi
-    python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
+    python_libs=`${python_config} --ldflags`
    if test $? != 0; then
      have_python_config=failed
      if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --ldflags)
+        AC_ERROR(failure running ${python-config} --ldflags)
      fi
    fi
-    python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
+    python_prefix=`${python_config} --exec-prefix`
    if test $? != 0; then
      have_python_config=failed
      if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --exec-prefix)
+        AC_ERROR(failure running ${python-config} --exec-prefix)
      fi
    fi
  else
复制代码

以上结果可以另存为patch,使用git apply 文件.patch 即可