Differences for a certain folder between git branches
Solution 1
You can use
git diff master..yourbranch -- path/to/folder
Solution 2
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.
Wazery
Software Engineer | ex-GSoCer《2012》| GSoC 2013 Mentor | KDE Developer | Ubuntu Official Member | Rails Contributor | CS Graduate | Fan of {OpenSource, SciFi, Tennis, Electro Music}. Areas of familiarity: Web Programming (Ruby on Rails, CSS, HTML, JavaScript) C/C++ Qt Linkedin: wazery Github: wazery Twitter: wazery_ http://stackexchange.com/users/flair/98894.png
Updated on April 09, 2020Comments
-
Wazery about 4 years
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.
-
Wazery over 11 yearsCan I specify a certain committer and how to extract this diff to a txt file.
-
jolivier over 11 yearswhat do you mean by extracting a certain commiter? retrieve the last commit of this person? To write this diff to a file you juste redirect the output like this ` git diff master..yourbranch path/to/file > filename
-
Wazery over 11 yearsI mean to extract only commits added by a certain author in my branch.
-
jolivier over 11 yearsbut between which ones do you want to diff? the last one?
-
Wazery over 11 yearsI need a diff for a certain author commits between master and mybranch
-
niklas over 7 yearsI get
fatal: bad revision 'master..develop_content'
-
Karl Henselin about 5 yearsMake sure that you have the branches checked out locally if you get that error.
-
Florian Wendelborn about 4 yearsAlternatively,
git fetch
andgit diff master..origin/develop_content
-
Shashank Bhatt over 3 yearsI tried this command but it is not showing all differences. Only new file is shown.
-
jolivier over 3 years@ShashankBhatt
git diff
has a lot of options that you can learn viagit help diff
. In your case maybe you staged some of the difference and need to add--staged
to the command in the answer to see them. -
Admin almost 2 yearsYou now need to add two hyphens to separate the branches from the path:
git diff master..yourbranch -- path/to/folder