From ccf52716ea6d3d0708bf3e0207d4d4a2b95db2c5 Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:44:43 +0100 Subject: [PATCH 1/9] no need to add git in double quotation when you want to set alias. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ccfe4a..8334fcc 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,8 @@ Files in a repository go through three stages before being under version control >> git config --global user.email "example@gmail.com" >> git config --global --list | -L # get list of gloabl configs >> git config --global --edit # --edit for edit git configs ->> git config --local alias.st "git status" # add alias for git commands ->> git config --local alias.gloa "git log --oneline --all" +>> git config --local alias.st "status" # add alias for git commands +>> git config --local alias.gloa "log --oneline --all" # Session 07 : Create Repository >> git init # initial repository From 78e8c6f3bd4e4d627de75d464fbca65dde952ab4 Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:48:21 +0100 Subject: [PATCH 2/9] Add 'filename' when use 'restore'. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8334fcc..b8e6c09 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ Files in a repository go through three stages before being under version control >> git checkout >> git checkout -b branch_name commID # checkout in commID and create new branch >> git checkout -b branch_name tag_name # checkout in tag_version and create new branch ->> git restore +>> git restore filename >> git restore index.txt # restore unstaged parts of file to head => see that with "git diff" >> git restore --staged index.txt # restore staging parts of file to unstaged => see that with "git diff --staged" >> git restore --source HEAD index.txt # restore staging part of file and unstaging part of file => see that with "git diff head" From 83f7e9b3e5d6f4b329e48ea2ef00316b9c5b48c7 Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:52:40 +0100 Subject: [PATCH 3/9] Add a table to compare 'git revert' and 'git reset'. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index b8e6c09..da2a2f6 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,16 @@ Files in a repository go through three stages before being under version control # Session 17 : Git revert >> git revert +# Compare Reset and Revert + +| Feature | `git reset` | `git revert` | +|------------------------------|--------------------------------------|---------------------------------------| +| **Purpose** | Move HEAD and modify history | Create a new commit that undoes changes | +| **History Modification** | Yes, it rewrites history | No, it preserves history | +| **Data Loss Potential** | Yes, especially with `--hard` | No, it preserves previous commits | +| **Use Case** | Undo commits, unstage changes | Safely undo changes in shared repositories | +| **Safe for Collaboration** | Not safe, can disrupt others' work | Safe, maintains history for all users | + # Session 18 : Git branching >> git branch # list of all local branchs >> git branch -r # list of all remote branchs From 9b6f39fd61ebe297457cd004b358102dd66691db Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:54:35 +0100 Subject: [PATCH 4/9] Add comment for 'git branch -d branch_name'. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da2a2f6..dc92c2d 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ Files in a repository go through three stages before being under version control >> git branch # list of all local branchs >> git branch -r # list of all remote branchs >> git branch -a # list of all branchs (local branchs and remote branchs) ->> git branch -d branch_name +>> git branch -d branch_name # delete the branch >> git branch branch_name # create branch >> git switch branch_name # switch in branchs >> git switch -c branch_name # create and switch branch From 776ddc3c5cf86d07f324aa86bb12a83f8da11f6c Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:56:57 +0100 Subject: [PATCH 5/9] Add 'git diff branch1..branch2' to show the differences between the two branches. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dc92c2d..ed44da0 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Files in a repository go through three stages before being under version control >> git diff --staged filename #show all changes that were staged in a specific file >> git diff HEAD #show all changes that were not commited, whether staged or not >> git diff #show all changes that were not staged +>> git diff branch1..branch2 #show the differences between branch1 and branch2 # Session 15 : Time travel (git checkout, git restore) >> git checkout From f9f1e53628f3f69937619202289aae87ca60932f Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 10:58:52 +0100 Subject: [PATCH 6/9] Remove '>> git ignore' because there is not command like this in git. --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index ed44da0..bbfe301 100644 --- a/README.md +++ b/README.md @@ -226,9 +226,6 @@ Files in a repository go through three stages before being under version control # Session 23 : Git cherry-pick >> git cherry-pick -# Session 24 : Git ignore ->> git ignore - # Session 25 : Git tag >> git tag # list of tags >> git tag -l 'v1.4.2.1.*' From c963e464f92cef7fc7ced21c6858ec5b1d077b3c Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 11:01:07 +0100 Subject: [PATCH 7/9] Add 'git checkout '. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bbfe301..9034c4c 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,7 @@ Files in a repository go through three stages before being under version control >> git show v1.0.0 >> git checkout -b branch_name commID # checkout in commID and create new branch >> git checkout -b branch_name tag_name # checkout in tag_version and create new branch +>> git checkout # transfer temporarily to a specific commit to check the code in that step and to come back use "git switch -" # Session 26 : Git blame >> git blame From 2d809a87eac735aaaf9ae1f27c1f456dc7bd33c1 Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 11:14:10 +0100 Subject: [PATCH 8/9] Add 'git rm filename'. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9034c4c..442ed77 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,9 @@ Files in a repository go through three stages before being under version control >> git commit --amend # amend commit >> git commit --amend --no-edit +# Git Remove file +>> git rm filename + # Session 10 : Git history >> git log # log of commits with date, descriptions and author Name >> git log --oneline # summary of git log From 104f2980b29106a71d81de451fa4071ee3718aaf Mon Sep 17 00:00:00 2001 From: Amirali Date: Wed, 30 Oct 2024 11:17:25 +0100 Subject: [PATCH 9/9] Capitalize 'head'. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 442ed77..b761bd6 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ Files in a repository go through three stages before being under version control # Session 26 : Git blame >> git blame >> git blame -L 1,10 # line 1 to 10 ->> git blame head +>> git blame HEAD >> git blame >> git blame