From a9372bcc2ce4c279087df031082df5dd6bf0ae0e Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Tue, 23 Jan 2024 22:27:48 +0800 Subject: Add git diff shortcuts --- git.cheat | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'git.cheat') 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 # Get the remote url of origin git remote get-url origin +# Diff a specific file between commits +git diff \ + --color-words \ + --ignore-space-change \ + .. \ + -- + +# Diff files changed compared to master branch +git diff \ + --color-words \ + --ignore-space-change \ + -- + +# Show the files changed compare to master branch +git diff --stat --merge-base + $ 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 .. + +$ master_branch: git symbolic-ref --short refs/remotes/origin/HEAD +$ files_changed_compared_to_master_branch: git diff --name-only --merge-base -- cgit v1.2.3