How to execute git diff in a specific directory

git diff really runs diff for all source codes, how to do it in a specific directory so that I can view the changes in the files under it.

+104
git
Dec 05 2018-11-11T00:
source share
4 answers

Specify the path (in this case, myfolder) and simply run:

git diff myfolder/

+98
Dec 05 '11 at 7:13
source share
β€” -

If you are comparing different branches, you need to use -- to separate the git version from the file system path. For example, with two local branches, master and bryan-working :

 $ git diff master -- AFolderOfCode/ bryan-working -- AFolderOfCode/ 

Or from the local branch to the remote:

 $ git diff master -- AFolderOfCode/ origin/master -- AFolderOfCode/ 
+46
Jun 22 '15 at 2:09
source share

You should get used to looking at documentation for such things. This is very useful and will improve your skills very quickly. Here's the corresponding bit when you do git help diff

  git diff [options] [--no-index] [--] <path> <path> 

Two <path> is what you need to change in the corresponding directories.

+5
Dec 05 '11 at 7:21
source share

Add Beyond Compare as your diffftool in git and add an alias for diffdir as:

 git config --global alias.diffdir = "difftool --dir-diff --tool=bc3 --no-prompt" 

Get gitdiff as:

 git diffdir 4bc7ba80edf6 7f566710c7 

See: https://truncatedcodr.wordpress.com/2014/09/20/compare-entire-directories-w-git-difftool-beyond-compare/

+3
Aug 28 '15 at 7:22
source share



All Articles