Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git retrieve a list of all files modified in a branch

Tags:

git

branch

linux

How can I get a list of all the files that were changed in a branch? I can't do a git-diff because the branch is already merged into master.

I would need a way to list all the commits in a branch and extract the path of the files, without duplicates.

If anybody has done a thing like this before it will be really appreciated,

a lot of thanks!

like image 266
Marco Antonio Avatar asked Oct 24 '12 08:10

Marco Antonio


People also ask

How do you see what files were changed in git?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

How do I get all changes from the main branch?

To get all the changes from all the branches, use git fetch --all . And if you'd like to clean up some of the branches that no longer exist in the remote repository, git fetch --all --prune will do the cleaning up!

Which command is used to get the list of all the available branches?

To get a list of all branches from the remote, run this command: git pull.


2 Answers

If we consider your branch as BranchA wich was branched from master, you can do:

git diff --name-status `git merge-base BranchA master`..BranchA

This will give you the list of changed files in branch prefixed with status (M for modified, A for added, D for deleted).

like image 91
Michaël Burtin Avatar answered Oct 25 '22 00:10

Michaël Burtin


This works if the branch is pointing to the merge commit:

git diff branch_name^..master --name-only
like image 25
Ikke Avatar answered Oct 25 '22 01:10

Ikke