Git 2 个分支之间的差异仅显示在功能分支中所做的更改
Git difference between 2 branches show changes made in feature branch only
如何获得我的功能分支 w.r.t 主分支的 git 差异。我只想要 feature 分支中的更改并排除 master 分支的更改。
E.g.If 功能分支有以下提交:
- b
- c
- e
- f
而 master 有以下提交:
- 一个
- d
- e
- f
然后我想要在提交 b 和 c 中修改的所有目录名称(不需要提交散列只是目录名称)。到目前为止,我已经尝试过 git --name-only diff master..feature
命令,但它似乎正在返回所有更改。
首先想到的是
git diff --name-only $(git merge-base master feature) feature
单击在 git hub/bitbucket
中创建 Pull Request
或您正在使用的任何内容。基本分支应为 master
。你可以看到变化。 Include/exclude feature 分支中的更改,然后将其合并到 master
.
@Mark's 回答确实帮助我找到了我要找的东西,非常感谢。但是对于本地分支名称,我也得到了很多条目,包括没有任何更改的 .gitignore。以下是对我有用的内容,它是对 Mark 原始答案的轻微修改:
git diff --name-only $(git merge-base remotes/origin/master remotes/origin/feature) remotes/origin/feature
这正是我要找的东西。
如何获得我的功能分支 w.r.t 主分支的 git 差异。我只想要 feature 分支中的更改并排除 master 分支的更改。 E.g.If 功能分支有以下提交:
- b
- c
- e
- f
而 master 有以下提交:
- 一个
- d
- e
- f
然后我想要在提交 b 和 c 中修改的所有目录名称(不需要提交散列只是目录名称)。到目前为止,我已经尝试过 git --name-only diff master..feature
命令,但它似乎正在返回所有更改。
首先想到的是
git diff --name-only $(git merge-base master feature) feature
单击在 git hub/bitbucket
中创建 Pull Request
或您正在使用的任何内容。基本分支应为 master
。你可以看到变化。 Include/exclude feature 分支中的更改,然后将其合并到 master
.
@Mark's 回答确实帮助我找到了我要找的东西,非常感谢。但是对于本地分支名称,我也得到了很多条目,包括没有任何更改的 .gitignore。以下是对我有用的内容,它是对 Mark 原始答案的轻微修改:
git diff --name-only $(git merge-base remotes/origin/master remotes/origin/feature) remotes/origin/feature
这正是我要找的东西。