(git)diff输出相对路径? [英] (git) diff output relative path?
问题描述
我需要在我的回购库中获得一些与回购基础不相关的差异,而是相对于给定基础或给定路径。
通过默认我得到:
git diff
diff --git a / path / to / file b / path / to / file
index 0cc125e..9bf911e 100644
--- a / path / to / file
+++ b / path / to / file
但我想要的是这样的:
git diff --prefix = / new / path / to
diff --git a / new / path / to / file b / new / path / to / file
index 0cc125e..9bf911e 100644
--- a / new / path / to / file
+++ b / new / path / to / file
我查看了--relative选项(不是我在找的),--src / dst-prefix(这些只能改变a或b部分。我是否缺少一些基本的东西?
解决方案看起来像
- src-prefix
和- dst-prefix
是所要求的:
$ cd ... / git / builtin
$ ed - var.c<<结束
> 0a
> xxx
> 。
> wq
> end
$ git diff
diff --git a / builtin / var.cb / builtin / var.c
index aedbb53..5210013 100644
--- a /内建/ var.c
+++ b / builtin / var.c
@@ -1,3 +1,4 @@
+ xxx
/ *
* GIT - 来自地狱的信息经理
*
(到目前为止,非常标准;现在: )
$ git diff --src-prefix = a / new / --dst-prefix = b / new /
diff --git a / new / builtin / var.cb / new / builtin / var.c
index aedbb53..5210013 100644
--- a / new / builtin / var.c
+++ b / new / builtin / var.c
@@ -1,3 +1,4 @@
+ xxx
/ *
* GIT - 来自地狱的信息管理员
*
您可以将它与
--relative
:
$ git diff --relative --src-prefix = a / new / --dst-prefix = b / new /
diff --git a / new / var.cb / new / var.c
index aedbb53..5210013 100644
--- a /new/var.c
+++ b / new / var.c
@@ -1,3 +1,4 @@
+ xxx
/ *
* GIT - 信息来自地狱的离子经理
*
$
I need to get some diffs in my repo that are not relative to the base of the repo, but instead relative to a given base or given path.
By default I get:
git diff diff --git a/path/to/file b/path/to/file index 0cc125e..9bf911e 100644 --- a/path/to/file +++ b/path/to/file
But what I want is something like:
git diff --prefix=/new/path/to diff --git a/new/path/to/file b/new/path/to/file index 0cc125e..9bf911e 100644 --- a/new/path/to/file +++ b/new/path/to/file
I have looked over the --relative option (not what I am looking for), the --src/dst-prefix (these can only change the "a" or "b" parts. Am I missing something basic?
解决方案Seems like
--src-prefix
and--dst-prefix
are what you're asking for:$ cd .../git/builtin $ ed - var.c << end > 0a > xxx > . > wq > end $ git diff diff --git a/builtin/var.c b/builtin/var.c index aedbb53..5210013 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -1,3 +1,4 @@ +xxx /* * GIT - The information manager from hell *
(so far, pretty standard; now:)
$ git diff --src-prefix=a/new/ --dst-prefix=b/new/ diff --git a/new/builtin/var.c b/new/builtin/var.c index aedbb53..5210013 100644 --- a/new/builtin/var.c +++ b/new/builtin/var.c @@ -1,3 +1,4 @@ +xxx /* * GIT - The information manager from hell *
You can combine this with
--relative
:$ git diff --relative --src-prefix=a/new/ --dst-prefix=b/new/ diff --git a/new/var.c b/new/var.c index aedbb53..5210013 100644 --- a/new/var.c +++ b/new/var.c @@ -1,3 +1,4 @@ +xxx /* * GIT - The information manager from hell * $
这篇关于(git)diff输出相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文