diff --git a/knowledge base/git.md b/knowledge base/git.md index 98fcf29..4df00ef 100644 --- a/knowledge base/git.md +++ b/knowledge base/git.md @@ -112,6 +112,7 @@ git log -p 'feature' --not 'master' # Just show changes between two files. git diff --no-index 'path/to/file/a' 'path/to/file/b' +git diff --no-index --word-diff --patience 'path/to/file/A' 'path/to/file/B' # Stage changes for commit. git add . @@ -584,6 +585,7 @@ git diff --word-diff='porcelain' # DO NOT consider them part of of the repository. # This can be used to diff any two files. git diff --no-index 'path/to/file/A' 'path/to/file/B' +git diff --no-index --word-diff --patience 'path/to/file/A' 'path/to/file/B' ``` Better word-aware diff: diff --git a/snippets/diff.sh b/snippets/diff.sh new file mode 100644 index 0000000..220ca38 --- /dev/null +++ b/snippets/diff.sh @@ -0,0 +1,12 @@ +#!sh + +# Sources: +# - https://stackoverflow.com/questions/8800578/how-to-colorize-diff-on-the-command-line + +git diff --no-index 'file1' 'file2' +git diff --no-index --word-diff --patience 'file1' 'file2' + +vimdiff 'file1' 'file2' + +diff 'file1' 'file2' +diff -y -W 'width' 'file1' 'file2' diff --git a/snippets/view.sh b/snippets/view.sh new file mode 100644 index 0000000..b099433 --- /dev/null +++ b/snippets/view.sh @@ -0,0 +1,4 @@ +#!sh + +# Just `vim` but read-only. +view 'file'