Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all modified files in git merge commit - even the fast forwarded

I'm thinking if there is a way that when I merge a branch into another branch that ALL changed files are listed in my commit message and not just the ones which were modified in both branches. This would give me a better overview of what was changed in the branch just by seeing the merge commit. Is there a way to do this?

like image 539
soupdiver Avatar asked Feb 05 '13 21:02

soupdiver


People also ask

Does a fast forward merge create a commit?

Fast forward merge can be performed when there is a direct linear path from the source branch to the target branch. In fast-forward merge, git simply moves the source branch pointer to the target branch pointer without creating an extra merge commit.

How do I see files changed in a specific 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.

What happens in a fast forward merge in git?

Fast-forward merges literally move your main branch's tip forward to the end of your feature branch. This keeps all commits created in your feature branch sequential while integrating it neatly back into your main branch.

Does git merge fast forward by default?

By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded.


2 Answers

I don't know how to do that in the commit message. But after the merge, this will give the names of all the files affected by the merge commit:

git log -m --name-only 

For only a list of filenames of the commit:

git log -m -1 --name-only --pretty="format:" <Merge SHA> 

There is some white space due to the merge having two parents but that can be easily removed.

like image 134
Schleis Avatar answered Oct 04 '22 05:10

Schleis


You can also use the diff command to see the difference between any two commits. If the branches haven't been merged yet, you can specify the branch names and compare them, otherwise you might need to find where they diverged (like so) an the last commit before they were merged back together.

git diff --name-status <commit> <commit> 

-name-status Show only names and status of changed files. 

like image 39
Roman Avatar answered Oct 04 '22 04:10

Roman