From d0ffb9b07bb59183ab499dbaf8782aea1f47d7c7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 3 Jul 2023 23:52:00 +0200 Subject: Add info about diff --- tools/git.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tools') diff --git a/tools/git.md b/tools/git.md index 2e962d2..52a4ba2 100644 --- a/tools/git.md +++ b/tools/git.md @@ -38,6 +38,7 @@ 3. Set up the alias 'config' ```bash $ alias config='/usr/bin/git --git-dir= --work-tree=$HOME' + alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME' ``` 4. Set local configuration into .cfg to ignore untracked files ```bash @@ -123,6 +124,35 @@ other's existence: ```bash $ git pull origin  --allow-unrelated-histories ``` +Diff between commits +``` +$ git log +$ git diff (checkout_id):file.txt file.txt +or +$ git diff +or +$ git difftool + +``` + + +If the top commit is pointed to by HEAD then you can do something like this: + +commit1 -> HEAD +commit2 -> HEAD~1 +commit3 -> HEAD~2 + +Diff between the first and second commit: + +git diff HEAD~1 HEAD + +Diff between first and third commit: + +git diff HEAD~2 HEAD + +Diff between second and third commit: + +git diff HEAD~2 HEAD~1 - - - #### Miscellaneous Find out size of a repo before cloning it -- cgit v1.2.3