git 文件的工作副本与其在另一个分支上的版本之间的差异
git diff between working copy of the file and its version on another branch
我知道以前有人问过类似的问题并回答过,但我尝试过的问题都不适合我。我在我的开发分支上,我想从 master 分支的头部复制一个文件到我的工作目录,所以我执行以下操作:
git checkout origin/master -- <my relative path>
复制工作正常,我可以看到文件时间戳已更新。要检查文件内容,我调用 git diff
:
git diff <my branch> origin/master -- <my relative path>
而且我仍然看到我的分支和 origin/master
之间存在一些差异。
我做错了什么?
(git 版本 1.7.9.5)
git diff <my branch> origin/master -- <my relative path>
这将区分提交到分支的内容,与您的本地更改无关。 the git-diff documentation 描述你想做什么:
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.
试试这个:
git diff origin/master -- <my relative path>
git diff <my branch> origin/master -- <my relative path>
表示区分 上次提交给您的分支的内容 和 origin/master。来自 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.
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view the changes between two arbitrary <commit>.
您想区分工作副本和 origin/master。
git diff origin/master -- <my relative path>
我知道以前有人问过类似的问题并回答过,但我尝试过的问题都不适合我。我在我的开发分支上,我想从 master 分支的头部复制一个文件到我的工作目录,所以我执行以下操作:
git checkout origin/master -- <my relative path>
复制工作正常,我可以看到文件时间戳已更新。要检查文件内容,我调用 git diff
:
git diff <my branch> origin/master -- <my relative path>
而且我仍然看到我的分支和 origin/master
之间存在一些差异。
我做错了什么?
(git 版本 1.7.9.5)
git diff <my branch> origin/master -- <my relative path>
这将区分提交到分支的内容,与您的本地更改无关。 the git-diff documentation 描述你想做什么:
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.
试试这个:
git diff origin/master -- <my relative path>
git diff <my branch> origin/master -- <my relative path>
表示区分 上次提交给您的分支的内容 和 origin/master。来自 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.
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view the changes between two arbitrary <commit>.
您想区分工作副本和 origin/master。
git diff origin/master -- <my relative path>