Kumar
Kumar

Reputation: 11

Need a git command which gives only my source branch(working branch) changes

I want to list the names of all files changed in a PR in Git/GitHub using powershell command.

I have tried various "git diff --name-only" commands which gives me the commit list between my sourcebranch(working branch) and target branch(Master). But I need a command that will list ONLY the changed files in a PULL REQUEST.

Can some one please help me out.

Upvotes: 1

Views: 404

Answers (2)

Frank Wang-MSFT
Frank Wang-MSFT

Reputation: 1407

In general, you can use the following command to list files that changed between any two commits git diff --name-only .

So if all of your branches originate with master, then you can use the below command to get the changes.

git --no-pager diff --name-only sourcebranchname $(git merge-base {sourcebranchname} {targetbranchname})

For example, I create a Pull request from branch1 to master, then the command should be like below.

git --no-pager diff --name-only branch1 $(git merge-base branch1 master)

Upvotes: 1

QipingF
QipingF

Reputation: 31

"git log --name-only" command will show the changed files in a branch. If you only want to check a certain commit, you may use "git show 123abc...(the commit ID) --name-only".

You may also use "git log --stat" command to get more detailed information about the changed files.

Upvotes: 2

Related Questions