er.animesh
er.animesh

Reputation: 59

Git difference between 2 branches show changes made in feature branch only

How can I get git difference of my feature branch w.r.t master branch. I only want changes that are there in the feature branch and exclude changes of master branch. E.g.If feature branch has following commits:

Whereas master has following commits:

Then I want all directory names that were modified in just the commit b & c (don't need commit hash just the directory names). I have so far tried git --name-only diff master..feature command but it seems it is returning all the changes.

Upvotes: 0

Views: 553

Answers (3)

er.animesh
er.animesh

Reputation: 59

@Mark's answer really helped me find what I was looking for, thanks a lot for that. But with local branch names I was also getting a lot of entries including the .gitignore which did not have any changes. What worked for me is following, which is a slight modification of Mark's original answer:

git diff --name-only $(git merge-base remotes/origin/master remotes/origin/feature) remotes/origin/feature

This gave me exactly what I was looking for.

Upvotes: 0

Chakreshwar Sharma
Chakreshwar Sharma

Reputation: 2610

Click on create Pull Request in git hub/bitbucket or whatever you are using. Base branch should be master. You can see the changes. Include/exclude the changes in feature branch and then merge it in master.

Upvotes: 0

Mark Adelsberger
Mark Adelsberger

Reputation: 45819

The first way that comes to mind is

git diff --name-only $(git merge-base master feature) feature

Upvotes: 1

Related Questions