如何区分对特定分支的本地更改?
how to diff a local change to a specific branch?
这是我遇到的情况,我认为这很常见:
- 分支
master
上的文件 A。
- i
fork master
变成 feature
- 现在我在更改文件 A 的功能分支上添加了几个提交。
- 我撤消了几次编辑(通过更多地编辑文件以删除更改),以便文件在 branch master 中是相同的,因为我的更改不是那么聪明
- 我做了一个新的改变,想看看我是否删除了之前的所有内容
- 我的第一次尝试是
git diff master...
但这显示了与 git diff
相同的差异,它没有显示从 master 到现在的变化。
示例内容和差异
$ git checkout master
$ cat a
line 1
line 2
$ git checkout feature
$ cat a
line 1-1
line 2-2
line 3
line 4
$ edit a #< from now on a is not indexed, it is locally edited
$ cat a
line 1
line 2
line 3
$ git diff
--- a
- line 1-1
- line 1-2
+ line 1
+ line 2
line 3
- line 4
$ git diff master...
--- a
- line 1-1
- line 1-2
+ line 1
+ line 2
line 3
- line 4
我想要得到的差异是:
$ git diff ???
--- a
line 1
line 2
+ line 3
就这样:
git diff master
没有“..”。
发件人:http://git-scm.com/docs/git-diff
git diff [--options] <commit> [--] [<path>…]
This form is to view the changes you have in your working tree
relative to the named <commit>
. You can use HEAD to compare it with
the latest commit, or a branch name to compare with the tip of a
different branch.
这是我遇到的情况,我认为这很常见:
- 分支
master
上的文件 A。 - i
fork master
变成feature
- 现在我在更改文件 A 的功能分支上添加了几个提交。
- 我撤消了几次编辑(通过更多地编辑文件以删除更改),以便文件在 branch master 中是相同的,因为我的更改不是那么聪明
- 我做了一个新的改变,想看看我是否删除了之前的所有内容
- 我的第一次尝试是
git diff master...
但这显示了与 git diff
相同的差异,它没有显示从 master 到现在的变化。
示例内容和差异
$ git checkout master
$ cat a
line 1
line 2
$ git checkout feature
$ cat a
line 1-1
line 2-2
line 3
line 4
$ edit a #< from now on a is not indexed, it is locally edited
$ cat a
line 1
line 2
line 3
$ git diff
--- a
- line 1-1
- line 1-2
+ line 1
+ line 2
line 3
- line 4
$ git diff master...
--- a
- line 1-1
- line 1-2
+ line 1
+ line 2
line 3
- line 4
我想要得到的差异是:
$ git diff ???
--- a
line 1
line 2
+ line 3
就这样:
git diff master
没有“..”。
发件人:http://git-scm.com/docs/git-diff
git diff [--options] <commit> [--] [<path>…]
This form is to view the changes you have in your working tree relative to the named
<commit>
. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.