I am trying to create a colorized diff between two folders in the same repository (This may be the totally wrong approach).
I believe one way of achieving this is through git diff --no-index folder1 folder2 and it will automatically create a patch for you (Cool).
However, the diff also includes (as one might expect), all of the .gitignore'd files as well.
folder1
node_modules
src/
.gitignore
package.json
README.md
folder2
node_modules
src/
.gitignore
package.json
README.md
I would like to ignore node_modules.
Possibilities? Alternatives?
Cheaty version:
git diff $(git commit-tree -m '' @:folder1) $(git commit-tree -m '' @:folder2)
which makes an on-the-fly commit for each tree (as they were on checkout) and diffs the two commits.
You can easily make scratch commits if you want to do this for the current worktree contents,
( export GIT_INDEX_FILE=.git/scratch-index
git add .
temp=`git write-tree`
git diff $(git commit-tree -m '' $temp:folder1) $(git commit-tree -m '' $temp:folder2)
)
and for finer control over what you're using you can pipe git ls-files with whatever pathspecs you want to git update-index --add --stdin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With