Differences for a certain folder between git branches

GitVersion ControlDiffGit Diff

Git Problem Overview


As in the title, I want to have a diff file for a certain folder between the master branch and a branch I have created.

Git Solutions


Solution 1 - Git

You can use

git diff master..yourbranch path/to/folder

Solution 2 - Git

git diff compares trees (as in hierarchies of source files at two different points in time), so it can't extract the changes done by a certain author. If you want to see what changes a user committed, then you need git log.

Does this solve your need?

git log --author=jdoe oldbranch..newbranch -p -- path/to/subdirectory > myChangesInSubdirectory.patch

This lists each commit done by jdoe between the two commits, printing them as a patch instead of the usual commit summary, limiting only to commits that have changes in the target subdirectory, and redirects the output to a file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWazeryView Question on Stackoverflow
Solution 1 - GitjolivierView Answer on Stackoverflow
Solution 2 - GitSergiu DumitriuView Answer on Stackoverflow