[英]How to find out what files were changed in a git branch (not the difference between two branches)
I have a branch named feature_219
which was created from master
a little while ago. 我有一个名为
feature_219
的分支,它是在不久前从master
创建的。 Since the diversion, there were a number of files changed on both the branches. 自从转移以来,两个分支上都有许多文件发生了变化。
Now I am trying to figure out what files where changed while working on the feature_219
branch only. 现在我试图弄清楚在处理
feature_219
分支时哪些文件发生了变化。
After doing some research I found out that git diff --name-only master feature_219
might help but it turned out that this commands tells about all files that are different in both the branches. 在做了一些研究之后,我发现
git diff --name-only master feature_219
可能会有所帮助,但事实证明这个命令告诉了两个分支中不同的所有文件。 I tried to look for some option with this command but nothing worked for me. 我试图用这个命令寻找一些选项,但没有任何对我有用。
Is there any way to list only those files that were changed in feature_219
branch? 有没有办法只列出那些在
feature_219
分支中更改的文件?
According to the git diff documentation 根据git diff文档
git diff --name-only master...feature_219
should do the trick. 应该做的伎俩。 Notice the three dots.
注意三个点。 If you're currently on branch
feature_219
如果您目前在分支
feature_219
git diff --name-only master...
suffices. 就足够了。 The order of the two branches is very important.
两个分支的顺序非常重要。 Interchanging the two branches in the first call will give you all changes in the
master
branch since you started the feature_219
branch. 在第一次调用中交换两个分支将在您启动
feature_219
分支后master
分支提供所有更改。
The command git diff A...B
should be interpreted as "give me all changes which happen in the commits when going from A
to B
". 命令
git diff A...B
应解释为“给我从A
到B
的提交中发生的所有更改”。 If A
is not a parent of B
(as in this case) the common ancestor will be used to answer this question. 如果
A
不是B
的父(在这种情况下),则共同的祖先将用于回答这个问题。
您可以使用git merge-base
查找两个分支的共同祖先,然后获取差异。
git diff --name-only feature_219 $(git merge-base master feature_219)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.