问题
I have a branch named feature_219
which was created from master
a little while ago. 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.
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. 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?
回答1:
You could use git merge-base
to find a common ancestor of two branches, then get the diff.
git diff --name-only feature_219 $(git merge-base master feature_219)
回答2:
According to the git diff documentation
git diff --name-only master...feature_219
should do the trick. Notice the three dots.
If you're currently on branch 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.
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
". If A
is not a parent of B
(as in this case) the common ancestor will be used to answer this question.
来源:https://stackoverflow.com/questions/29702692/how-to-find-out-what-files-were-changed-in-a-git-branch-not-the-difference-betw