aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2024-01-23 22:27:48 +0800
committerGuangxiong Lin <[email protected]>2024-01-23 22:27:48 +0800
commita9372bcc2ce4c279087df031082df5dd6bf0ae0e (patch)
treee3756fd56e81a3ec503404c4bb6cb66904a14ec6
parent6ebd2799984879e3520d1421cff4e8c0792c4758 (diff)
downloadnavi-cheats-a9372bcc2ce4c279087df031082df5dd6bf0ae0e.tar.gz
navi-cheats-a9372bcc2ce4c279087df031082df5dd6bf0ae0e.tar.bz2
navi-cheats-a9372bcc2ce4c279087df031082df5dd6bf0ae0e.zip
Add git diff shortcuts
-rw-r--r--git.cheat23
1 files changed, 23 insertions, 0 deletions
diff --git a/git.cheat b/git.cheat
index 33f396e..cf50d0b 100644
--- a/git.cheat
+++ b/git.cheat
@@ -15,5 +15,28 @@ git branch -d <branch>
# Get the remote url of origin
git remote get-url origin
+# Diff a specific file between commits
+git diff \
+ --color-words \
+ --ignore-space-change \
+ <start_commit_id>..<end_commit_id> \
+ -- <files_changed_between_commits>
+
+# Diff files changed compared to master branch
+git diff \
+ --color-words \
+ --ignore-space-change \
+ -- <files_changed_compared_to_master_branch>
+
+# Show the files changed compare to master branch
+git diff --stat --merge-base <master_branch>
+
$ commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
$ branch: git branch | awk '{print $NF}'
+
+$ start_commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
+$ end_commit_id: git log --pretty=reference --- --column 1 --delimiter '\s'
+$ files_changed_between_commits: git diff --name-only <start_commit_id>..<end_commit_id>
+
+$ master_branch: git symbolic-ref --short refs/remotes/origin/HEAD
+$ files_changed_compared_to_master_branch: git diff --name-only --merge-base <master_branch>