From 81866e88054c7ed857989871832e06dec9f68200 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:16:37 +0100 Subject: [PATCH 01/75] adding completory info to the sections 1-4 --- all-notes-from-tutorial.md | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 765ea818..65f25380 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -4,28 +4,35 @@ some notes for git learners # Git Commands -1. **Initialize a Git Project:** +1. **Initializing a Git Project:** To start a new Git repository for your project, use the following command: ``` git init ``` + - It creates a hidden .git folder, which stores all the repository’s + metadata (branches, commits, configurations, etc.). + - Used when starting a new project or making an existing directory a Git + repository. -2. **Check the Status:** +2. **Checking the Status:** To view the current status of your project and its files, use: ``` git status ``` + - Tells you which files are modified, staged, or untracked. + - Helps you understand what changes need to be committed. -3. **Add Files to the Staging Area:** +3. **Adding Files to the Staging Area:** Add files to the staging area to prepare them for commit. You have several options: - - Add all files: + - Add all (the changed) files: ``` git add -A ``` + - Add specific file types, e.g., all HTML files: ``` git add "*.html" @@ -36,14 +43,25 @@ some notes for git learners git add "file-name" ``` -4. **Commit Changes:** + - Add more than one file at the same time: + ``` + git add “file1.txt” “file2.txt” + ``` + + - Adding any file that have "hello" in its name: + ``` + git add “hello\*” + ``` + +4. **Committing Changes:** To save the staged changes as a new snapshot, use the `git commit` command: ``` - git commit -m "Your message about the changes" + git commit -m "Your comment about the changes" ``` - - `git commit`: Archive staged changes and add a descriptive message. - - Always include a message with your commit. + - `git commit`: You can also write this command (without adding -m "comment") and insert your comment in the editor. + - Always include a comment with your commit. + 5. **View Differences:** @@ -53,7 +71,6 @@ some notes for git learners ``` git diff HEAD ``` - - See the difference between the current stage and the previous stage: ``` git diff --staged From 05d6c35f4046de0d354f5be3262eaa11dfc81581 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:22:46 +0100 Subject: [PATCH 02/75] correcting wrong definitions for git diff HEAD and git diff --satged commands. also added the definition of HEAD. --- all-notes-from-tutorial.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 65f25380..60b139e9 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -67,11 +67,13 @@ some notes for git learners Git provides several ways to view differences: - - See the difference between the current stage and the last commit: + - See the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. ``` git diff HEAD ``` - - See the difference between the current stage and the previous stage: + - HEAD: is a special pointer that refers to the current branch's latest commit. However, the location of this pointer can be changed to any commit you want. + + - See the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. ``` git diff --staged ``` From 00d3292ab17c4db4b43855c4afafd6120856d277 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:22:46 +0100 Subject: [PATCH 03/75] correcting wrong definitions for git diff HEAD and git diff --satged commands. also added the definition of HEAD. --- all-notes-from-tutorial.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 65f25380..60b139e9 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -67,11 +67,13 @@ some notes for git learners Git provides several ways to view differences: - - See the difference between the current stage and the last commit: + - See the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. ``` git diff HEAD ``` - - See the difference between the current stage and the previous stage: + - HEAD: is a special pointer that refers to the current branch's latest commit. However, the location of this pointer can be changed to any commit you want. + + - See the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. ``` git diff --staged ``` From 773d1d8bd8c5d49cf346f0580f28c125244cb7a2 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:24:40 +0100 Subject: [PATCH 04/75] editting the title --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 60b139e9..42d359d0 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -63,7 +63,7 @@ some notes for git learners - Always include a comment with your commit. -5. **View Differences:** +5. **Viewing Differences:** Git provides several ways to view differences: From 141144f8682754a8454d3edab512db0a19dd9573 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:29:50 +0100 Subject: [PATCH 05/75] showing the difference between the two commands mentioned in this section by an example. --- all-notes-from-tutorial.md | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 42d359d0..7dd666f7 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -77,6 +77,53 @@ some notes for git learners ``` git diff --staged ``` + + Example: + + I make one change in the pag1.html, then add it to the stage then make + another change, without adding: + + + + + + + + + + + + + + + + + + +
$ git diff HEAD$ git diff --staged

diff --git a/page1.html b/page1.html

+

index d637411..b11a95a 100644

+

--- a/page1.html

+

+++ b/page1.html

+

@@ -2,5 +2,7 @@

+

<body>

+

project 1!

+

Hi there!

+

+ I am Jalal.

+

+ I love programming!

+

<html>

+

<body>

+

\ No newline at end of file

diff --git a/page1.html b/page1.html

+

index d637411..b2f8fc6 100644

+

--- a/page1.html

+

+++ b/page1.html

+

@@ -2,5 +2,6 @@

+

<body>

+

project 1!

+

Hi there!

+

+ I am Jalal.

+

<html>

+

<body>

+

\ No newline at end of file

6. **Reset and Exit the Staging Area:** From 27f6931470695f98e9700a911b32cc6193124bde Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:32:05 +0100 Subject: [PATCH 06/75] fixing the bug for table view --- all-notes-from-tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 7dd666f7..020f6dc9 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -77,8 +77,8 @@ some notes for git learners ``` git diff --staged ``` - - Example: + + Example: I make one change in the pag1.html, then add it to the stage then make another change, without adding: From eb0a9d649ba3bf1cb2fcc90f24ff2f7905a8ac2a Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:48:44 +0100 Subject: [PATCH 07/75] Editing and adding extra notes to the Restore section. --- all-notes-from-tutorial.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 020f6dc9..46ae21ad 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -125,7 +125,7 @@ some notes for git learners -6. **Reset and Exit the Staging Area:** +6. **Reseting and Exiting the Staging Area:** To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` command: @@ -144,18 +144,29 @@ some notes for git learners 7. **Restore Files:** - To manipulate the state of your working directory and staging area without affecting the commit history, you can use - the `git restore` command: + To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: - To unstage a file, use: ``` git restore --staged ``` + - it works similarly to the `(git reset "filename")` command. + + - To restore all staged files: + ``` + git restore --staged * + ``` + + - To restore file content back to latest commit: + ``` + git restore + ``` - To restore a specific file from a previous commit to your working directory, use: ``` git restore --source= ``` + - It restores the content of to match the version from the specified . This will overwrite the file in your working directory with the version from the given commit, but it won't affect the staging area or commit history. - To restore your entire working directory to match a specific commit, use: ``` From 59c3fc2872dac633b79810d2b482851e8a230b40 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 19:48:44 +0100 Subject: [PATCH 08/75] Editing and adding extra notes to the Restore section. --- all-notes-from-tutorial.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 020f6dc9..a9b026a7 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -50,7 +50,7 @@ some notes for git learners - Adding any file that have "hello" in its name: ``` - git add “hello\*” + git add “hello*” ``` 4. **Committing Changes:** @@ -125,7 +125,7 @@ some notes for git learners -6. **Reset and Exit the Staging Area:** +6. **Reseting and Exiting the Staging Area:** To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` command: @@ -144,18 +144,29 @@ some notes for git learners 7. **Restore Files:** - To manipulate the state of your working directory and staging area without affecting the commit history, you can use - the `git restore` command: + To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: - To unstage a file, use: ``` git restore --staged ``` + - it works similarly to the `(git reset "filename")` command. + + - To restore all staged files: + ``` + git restore --staged * + ``` + + - To restore file content back to latest commit: + ``` + git restore + ``` - To restore a specific file from a previous commit to your working directory, use: ``` git restore --source= ``` + - It restores the content of to match the version from the specified . This will overwrite the file in your working directory with the version from the given commit, but it won't affect the staging area or commit history. - To restore your entire working directory to match a specific commit, use: ``` From 6565895b6ea85cc42f27894ac4db2c22af3ae521 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 20:03:22 +0100 Subject: [PATCH 09/75] Editting and adding notes to the branch section. --- all-notes-from-tutorial.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 17c00317..da9415b2 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -172,14 +172,20 @@ some notes for git learners git restore --source= . ``` -8. **Branches:** +8. **Working With Branches:** + + When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - - - Show all branches in the project: + - To show all branches in the project: ``` git branch ``` + - The output highlights your current working branch with an astrix (\*). + Example: + > \$ git branch + > + > fixhtml + > \* master - Create a new branch for your project: ``` @@ -191,8 +197,6 @@ some notes for git learners git branch -d 'branch-name' ``` -9. **Checkout Branch and Files:** - - To switch to a different branch and replace all the files in your current branch with those from 'branch-name', use: ``` @@ -204,9 +208,6 @@ some notes for git learners ``` - `'--'`: Refers to the HEAD (latest commit). - -10. **Merge Branches:** - To merge a branch into your current branch, use: ``` git merge 'branch-name' From 954ea1da8b7d4505c1af58c23835c87e3e30fb95 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 20:03:22 +0100 Subject: [PATCH 10/75] Editting and adding notes to the branch section. --- all-notes-from-tutorial.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 17c00317..6887821f 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -172,14 +172,21 @@ some notes for git learners git restore --source= . ``` -8. **Branches:** +8. **Working With Branches:** + + When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - - - Show all branches in the project: + - To show all branches in the project: ``` git branch ``` + - The output highlights your current working branch with an astrix (\*). + Example: + > \$ git branch + > + > fixhtml + > + > \* master - Create a new branch for your project: ``` @@ -191,8 +198,6 @@ some notes for git learners git branch -d 'branch-name' ``` -9. **Checkout Branch and Files:** - - To switch to a different branch and replace all the files in your current branch with those from 'branch-name', use: ``` @@ -204,9 +209,6 @@ some notes for git learners ``` - `'--'`: Refers to the HEAD (latest commit). - -10. **Merge Branches:** - To merge a branch into your current branch, use: ``` git merge 'branch-name' From 98e1d4802257462095b235b99e5128edb259f035 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Mon, 17 Feb 2025 20:20:06 +0100 Subject: [PATCH 11/75] adding notes on branch section --- all-notes-from-tutorial.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 6887821f..e003d7d8 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -26,29 +26,29 @@ some notes for git learners 3. **Adding Files to the Staging Area:** - Add files to the staging area to prepare them for commit. You have several options: + To Add files to the staging area to prepare them for commit. You have several options: - - Add all (the changed) files: + - To add all (the changed) files: ``` git add -A ``` - - Add specific file types, e.g., all HTML files: + - To add specific file types, e.g., all HTML files: ``` git add "*.html" ``` - - Add specific file : + - To add a specific file : ``` - git add "file-name" + git add ``` - - Add more than one file at the same time: + - To add more than one file at the same time: ``` git add “file1.txt” “file2.txt” ``` - - Adding any file that has "hello" in its name: + - To add any file that has "hello" in its name: ``` git add “hello*” ``` @@ -131,7 +131,7 @@ some notes for git learners - To unstage a file, use: ``` - git reset 'filename' + git reset ``` - To move the HEAD pointer to a specific commit and optionally modify the staging area and working directory, use: @@ -149,7 +149,7 @@ some notes for git learners ``` git restore --staged ``` - - it works similarly to the `(git reset "filename")` command. + - it works similarly to the `(git reset )` command. - To restore all staged files: ``` @@ -188,12 +188,12 @@ some notes for git learners > > \* master - - Create a new branch for your project: + - To Create a new branch for your project: ``` git branch 'branch-name' ``` - - Delete a branch from the project: + - To delete a branch from the project: ``` git branch -d 'branch-name' ``` @@ -205,14 +205,14 @@ some notes for git learners ``` - To replace a file with the version from the HEAD (latest commit), use: ``` - git checkout -- 'filename' + git checkout -- ``` - `'--'`: Refers to the HEAD (latest commit). - To merge a branch into your current branch, use: - ``` - git merge 'branch-name' - ``` + - To merge a branch into your current branch, use: + ``` + git merge 'branch-name' + ``` 11. **View Commit History:** @@ -386,11 +386,11 @@ some notes for git learners - Show all the change history about your file: ``` - git blame 'filename' + git blame ``` - Show all the change history about your requested line in the requested file: ``` - git blame 'filename' -L5 + git blame -L5 ``` - Git Blame is useful for tracing the changes made to a file, and using the `-L` parameter, you can specify a specific line range to investigate. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. From 2232566d91793077c68454a9874c4ff595db6a4d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 00:56:43 +0100 Subject: [PATCH 12/75] completing the braanch section --- all-notes-from-tutorial.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index e003d7d8..c6763a4b 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -171,6 +171,14 @@ some notes for git learners ``` git restore --source= . ``` + + - To replace a file with the version from the HEAD (latest commit), use: + ``` + git checkout -- + ``` + - if you have not yet committed the changes, it will undo all changes and brings the file back to the previous commit file status. So, it restores all the changes back to the latest commit. + - `'--'`: Refers to the HEAD (latest commit). + 8. **Working With Branches:** @@ -203,16 +211,28 @@ some notes for git learners ``` git checkout 'branch-name' ``` - - To replace a file with the version from the HEAD (latest commit), use: - ``` - git checkout -- - ``` - - `'--'`: Refers to the HEAD (latest commit). + - so, let’s say you make a new branch and go to this branch, make some files and change the contents of the other. If you switch back the master using checkout, all the files and changes that you have made will disappear from your computer directory! - To merge a branch into your current branch, use: ``` git merge 'branch-name' ``` + - it merges the changes you made in the new branch on the branch master. note that before using this command you have to checkout first to the branch master. + - When you switch from one branch to the other (let’s say from master to a new branch named "linkingpages") the git bash interface will show a message, telling you what is different in your working directory compared to linkingpages after switching. D means deleted, and M means modified. + In this example, one file has been modified and one has been deleted, comparing the branch content with the working directory: + + > \$ git checkout linkingpages + > + > D 2_project.html + > + > M Git init.docx + > + > D index.txt + > + > Switched to branch 'linkingpages' + - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. + - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. + 11. **View Commit History:** From 0ab1ce385dc70a844fab68880ba605eb392cd9e2 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:04:32 +0100 Subject: [PATCH 13/75] merging two section into one --- all-notes-from-tutorial.md | 46 ++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index c6763a4b..399553e3 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -17,12 +17,16 @@ some notes for git learners 2. **Checking the Status:** - To view the current status of your project and its files, use: - ``` - git status - ``` - - Tells you which files are modified, staged, or untracked. - - Helps you understand what changes need to be committed. + - To view the current status of your project and its files, use: + ``` + git status + ``` + - Tells you which files are modified, staged, or untracked and helps you understand what changes need to be committed. + + - To see all the commit logs, use: + ``` + git log + ``` 3. **Adding Files to the Staging Area:** @@ -52,8 +56,14 @@ some notes for git learners ``` git add “hello*” ``` - -4. **Committing Changes:** + + +4. **Removing a file from the local repository:** + To remove a file from Git and your project, use: + ``` + git rm 'file-name' + ``` +5. **Committing Changes:** To save the staged changes as a new snapshot, use the `git commit` command: ``` @@ -62,7 +72,7 @@ some notes for git learners - `git commit`: You can also write this command (without adding -m "comment") and insert your comment in the editor. - Always include a comment with your commit. -5. **Viewing Differences:** +6. **Viewing Differences:** Git provides several ways to view differences: @@ -124,7 +134,7 @@ some notes for git learners -6. **Reseting and Exiting the Staging Area:** +7. **Reseting and Exiting the Staging Area:** To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` command: @@ -141,7 +151,7 @@ some notes for git learners git reset --hard ``` -7. **Restoring Files:** +8. **Restoring Files:** To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: @@ -180,7 +190,7 @@ some notes for git learners - `'--'`: Refers to the HEAD (latest commit). -8. **Working With Branches:** +9. **Working With Branches:** When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: @@ -234,19 +244,7 @@ some notes for git learners - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. -11. **View Commit History:** - To see all the commit logs, use: - ``` - git log - ``` - -12. **Remove a File:** - - To remove a file from Git and your project, use: - ``` - git rm 'file-name' - ``` 13. **Push to a Remote Repository:** From 106ffe7afecb88066f473e142787c8a09f55f544 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:09:54 +0100 Subject: [PATCH 14/75] adding new data to status section --- all-notes-from-tutorial.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 399553e3..deece8ac 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -17,16 +17,20 @@ some notes for git learners 2. **Checking the Status:** - - To view the current status of your project and its files, use: + - To view the current status of your local repository: ``` git status ``` - Tells you which files are modified, staged, or untracked and helps you understand what changes need to be committed. - - To see all the commit logs, use: + - To show the log (history) of the all commits you have made: ``` git log ``` + - To see the content of a specific commit: + ``` + git show + ``` 3. **Adding Files to the Staging Area:** @@ -244,8 +248,6 @@ some notes for git learners - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. - - 13. **Push to a Remote Repository:** To push all the changes from your local `master` branch to a remote repository (usually in the cloud, like GitHub or From 4151e690eeafe6494fec7378de7f2d06891a47ad Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:12:48 +0100 Subject: [PATCH 15/75] adding the definition of a repo --- all-notes-from-tutorial.md | 1 + 1 file changed, 1 insertion(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index deece8ac..07858945 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -5,6 +5,7 @@ some notes for git learners # Git Commands 1. **Initializing a Git Project:** + A repository (or repo) in Git is a storage location where your project's files, along with their entire version history, are stored. It tracks all changes, allowing you to collaborate, revert, and manage versions effectively. To start a new Git repository for your project, use the following command: ``` From e58619167e135245adafc8a0242cea1eab616ac4 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:20:39 +0100 Subject: [PATCH 16/75] Adding a new section for cloning and adding the initial explanations --- all-notes-from-tutorial.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 07858945..5130e3d0 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -248,7 +248,27 @@ some notes for git learners - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. - +10. **Cloning a Remote Repository** + + remote is a reference to a repository on a server, like github or + gitlab, or even another machine. If you clone a repository from + GitHub, Git automatically creates a remote reference called origin. + + origin is the default name given to a remote repository when you + clone a project. It acts as a shortcut to refer to the original + repository's URL, so you don’t have to type the full address every + time. + + In Git, a **remote is a reference** because it's essentially a + **pointer** or **label** that Git uses to keep track of where a + repository is located. So, a **remote** is a **reference to the + location of a repository**—this **location** can be a URL, and Git + uses that reference to fetch and push data. + + Technically speaking, Git stores remotes as **configuration entries** + in your repository. So, remote is a **configuration entry** stored as + plain text in the Git configuration file. Git keeps this information + in a special file called .git/config in your local repository. 13. **Push to a Remote Repository:** To push all the changes from your local `master` branch to a remote repository (usually in the cloud, like GitHub or From 73187fa2ec1a999b48708b9fba15a11328e0a8db Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:23:19 +0100 Subject: [PATCH 17/75] Adding an example to the clonning section --- all-notes-from-tutorial.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 5130e3d0..ab90ded9 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -263,12 +263,18 @@ some notes for git learners **pointer** or **label** that Git uses to keep track of where a repository is located. So, a **remote** is a **reference to the location of a repository**—this **location** can be a URL, and Git - uses that reference to fetch and push data. + uses that reference to fetch and push data. Technically speaking, Git stores remotes as **configuration entries** in your repository. So, remote is a **configuration entry** stored as plain text in the Git configuration file. Git keeps this information in a special file called .git/config in your local repository. + For example, a typical section in .git/config looks like this: + > \[remote "origin"\] + > + > url = https://github.com/user/repo.git + > + > fetch = +refs/heads/\*:refs/remotes/origin/\* + > + > This configuration section is where **origin** is the reference, and + > the **URL** (https://github.com/user/repo.git) is the data that Git + > uses to access the remote repository. - Technically speaking, Git stores remotes as **configuration entries** - in your repository. So, remote is a **configuration entry** stored as - plain text in the Git configuration file. Git keeps this information - in a special file called .git/config in your local repository. 13. **Push to a Remote Repository:** To push all the changes from your local `master` branch to a remote repository (usually in the cloud, like GitHub or From ebfdea7fbfe8719e0554f2593c48280cef1e9ec2 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:24:52 +0100 Subject: [PATCH 18/75] fixing the bug on the example --- all-notes-from-tutorial.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index ab90ded9..962896f4 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -271,9 +271,9 @@ some notes for git learners > > fetch = +refs/heads/\*:refs/remotes/origin/\* > - > This configuration section is where **origin** is the reference, and - > the **URL** (https://github.com/user/repo.git) is the data that Git - > uses to access the remote repository. + This configuration section is where **origin** is the reference, and + the **URL** (https://github.com/user/repo.git) is the data that Git + uses to access the remote repository. 13. **Push to a Remote Repository:** From 5e62ef9246773ff5e790f6682cc28624fa552837 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:27:46 +0100 Subject: [PATCH 19/75] adding the clone description --- all-notes-from-tutorial.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 962896f4..807c6f54 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -275,6 +275,12 @@ some notes for git learners the **URL** (https://github.com/user/repo.git) is the data that Git uses to access the remote repository. + clonning a project means making a copy of the remote project on your local directory. To do so we use this command: + ``` + git clone + ``` + + 13. **Push to a Remote Repository:** To push all the changes from your local `master` branch to a remote repository (usually in the cloud, like GitHub or From 3c869c10728cb836a2221e9b2236206e38a351eb Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:40:22 +0100 Subject: [PATCH 20/75] Completing cloning section --- all-notes-from-tutorial.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 807c6f54..02b16496 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -250,11 +250,11 @@ some notes for git learners 10. **Cloning a Remote Repository** - remote is a reference to a repository on a server, like github or + Remote is a reference to a repository on a server, like github or gitlab, or even another machine. If you clone a repository from GitHub, Git automatically creates a remote reference called origin. - origin is the default name given to a remote repository when you + Origin is the default name given to a remote repository when you clone a project. It acts as a shortcut to refer to the original repository's URL, so you don’t have to type the full address every time. @@ -275,10 +275,25 @@ some notes for git learners the **URL** (https://github.com/user/repo.git) is the data that Git uses to access the remote repository. - clonning a project means making a copy of the remote project on your local directory. To do so we use this command: - ``` - git clone - ``` + - Clonning a project means making a copy of the remote project on your local directory. To do so we use this command: + ``` + git clone + ``` + - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This is Git terminology is called "pulling". We pull the file from the origin and write them on the master branch + ``` + git pull origin master + ``` + - If you made some changes on your local repository, and want to effect them also on the remote repository, you "push" these changes from your master brach to the origin by: + ``` + git push origin master + ``` + - if you want to tell Git, to make this push path (from master branch to the origin), as a default pushing path, you need to first write: + ``` + git push -u origin master + ``` + (which -u stands for --set-upstream). the next time you want to do the same thing, you only + need to write `git push`. + 13. **Push to a Remote Repository:** From aab0464020c0988ad7c046bc5eb07c61c8508c70 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:41:55 +0100 Subject: [PATCH 21/75] Fixing a bug in the clone section --- all-notes-from-tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 02b16496..ca933e73 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -276,9 +276,9 @@ some notes for git learners uses to access the remote repository. - Clonning a project means making a copy of the remote project on your local directory. To do so we use this command: - ``` + ``` git clone - ``` + ``` - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This is Git terminology is called "pulling". We pull the file from the origin and write them on the master branch ``` git pull origin master From 2155ed8bd11429ccfcf87af4edd42612ce2efb64 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:47:04 +0100 Subject: [PATCH 22/75] clonning section: small adjustments --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index ca933e73..233b92a3 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -275,7 +275,7 @@ some notes for git learners the **URL** (https://github.com/user/repo.git) is the data that Git uses to access the remote repository. - - Clonning a project means making a copy of the remote project on your local directory. To do so we use this command: + - Clonning a project means making a copy of a remote project (like GitHub) on your local directory. To do so we use this command: ``` git clone ``` From fba2249f5920d5fbd755d4b28a64b51813d279cf Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:47:42 +0100 Subject: [PATCH 23/75] small adjustments --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 233b92a3..8b29b9a6 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -275,7 +275,7 @@ some notes for git learners the **URL** (https://github.com/user/repo.git) is the data that Git uses to access the remote repository. - - Clonning a project means making a copy of a remote project (like GitHub) on your local directory. To do so we use this command: + - Clonning a project means making a copy of a remote project from a remote location (like GitHub) on your local directory. To do so we use this command: ``` git clone ``` From 552796da954aa74935d24788a4cccfeaf463223b Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:54:41 +0100 Subject: [PATCH 24/75] Deleting and merging sections --- all-notes-from-tutorial.md | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 8b29b9a6..ee438473 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -279,11 +279,11 @@ some notes for git learners ``` git clone ``` - - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This is Git terminology is called "pulling". We pull the file from the origin and write them on the master branch + - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This in Git terminology is called "pulling". We pull the file from the origin and write them on the master branch: ``` git pull origin master ``` - - If you made some changes on your local repository, and want to effect them also on the remote repository, you "push" these changes from your master brach to the origin by: + - If you made some changes on your local repository, and want to send committed changes from your local repository to the remote server (usually in the cloud, like GitHub or GitLab), you "push" these changes from your master brach to the origin by: ``` git push origin master ``` @@ -296,38 +296,6 @@ some notes for git learners -13. **Push to a Remote Repository:** - - To push all the changes from your local `master` branch to a remote repository (usually in the cloud, like GitHub or - GitLab), use: - ``` - git push origin master - ``` - - `origin`: Represents the remote repository. - - `git push -u origin master`: After using this parameter, you can use `git push` instead - of `git push origin master`. - -14. **Pull from a Remote Repository:** - - To update, retrieve, and replace the changes from the remote repository into your local `master` branch, use: - ``` - git pull origin master - ``` - -15. **Clone a Repository:** - - To copy an existing repository from a remote location (like GitHub) to your local machine, use: - ``` - git clone - ``` - -16. **Push Changes to Remote:** - - To send committed changes from your local repository to the remote server, use: - ``` - git push - ``` - 17. **Add Remote Repository:** To add a remote address to your current project on your local machine, use: From be8e9102ef4ce3e4652a5f00a904c919a524dfe7 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 10:55:09 +0100 Subject: [PATCH 25/75] Fixing the title of Adding remote Repository --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index ee438473..451cc29b 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -296,7 +296,7 @@ some notes for git learners -17. **Add Remote Repository:** +11. **Adding a Remote Repository:** To add a remote address to your current project on your local machine, use: ``` From af3882aab7c6fdd88370df9670ade09b2bc27087 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:08:10 +0100 Subject: [PATCH 26/75] Completing the section 11 --- all-notes-from-tutorial.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 451cc29b..a2f2fd79 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -294,14 +294,26 @@ some notes for git learners (which -u stands for --set-upstream). the next time you want to do the same thing, you only need to write `git push`. - - 11. **Adding a Remote Repository:** - To add a remote address to your current project on your local machine, use: - ``` - git remote add origin - ``` + - To link a remote address to your current project on your local machine, use: + ``` + git remote add origin + ``` + - For starting a project, you make an empty repository on the cloud and link it to your local repository, to save and push files also on the cloud. + - You can add multiple remotes to your projects and push them into different repositories at the same time for increased safety. + - Origin is the default remote name. You can replace the origin with any name you want in this command. + + - To view the remotes attached to your local repository: + ``` + git remote + ``` + - To make the output of the previous command (-v stands for "verbous"): + ``` + git remote -v + ``` + - It will give you the name of the remote and the url, both for pull (fetch) and push. + 18. **Change Remote URL:** From b69ee58b46448de47dd07e0b79c501945b862583 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:23:23 +0100 Subject: [PATCH 27/75] finishing the section 11 --- all-notes-from-tutorial.md | 64 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index a2f2fd79..b72e4d68 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -308,40 +308,66 @@ some notes for git learners ``` git remote ``` + - To make the output of the previous command (-v stands for "verbous"): ``` git remote -v ``` - It will give you the name of the remote and the url, both for pull (fetch) and push. - -18. **Change Remote URL:** + - To replace the current remote URL with a new one, use: + ``` + git remote set-url origin + ``` - To replace the current remote URL with a new one, use: - ``` - git remote set-url origin - ``` + - To fetch and merge changes from the remote server into your default local branch, use: + ``` + git pull origin master + ``` + - You can substitute any branch name with master, if you want to pull changes to another branch. -19. **Pull Changes from Remote:** + - To push changes from your local default branch to the remote repository: + ``` + git push origin master + ``` + + - To track a remote branch, use: + ``` + git branch --set-upstream-to=origin/master master + ``` - To fetch and merge changes from the remote server into your local branch, use: - ``` - git pull origin main - ``` + - To push the current branch and set the remote as the upstream branch, use: + ``` + git push --set-upstream origin + ``` + + **Solving Conflicts** + So, let’s say I pulled the origin, made changes on one of the files. + And in the meanwhile, my colleague pulled and did some changes on the + same file and pushed the changes. So, it means that the current origin + state is not the same file when I fetch it. Now if I want to push, git + gives me error, saying that a conflict has happened and you cannot + make the changes you want on the origin file because it’s initial + state is changed. Usually, it guides you, telling you to pull again. + When you pull it, it tells you that you have some conflicts on the + file you have been working on. Git is rather smart, so that if you and + your colleague have changed different lines of that part, it + automatically merges the two changes and then it allows you to push. + However, if different changes have been applied to the same parts of + the code, it needs you to resolve the conflicts. So, if you use Vim + editor, you will see the changed parts highlighted in the file. Your + changes are between \<\<\<\<\<\<\< Header and =====, and his/her + changes are between \>\>\>\>\>\> (commit hash id) and =======. You can + decide which to keep and which to discard. you can also discard all + the signs (\<\<, \>\> and ===) 20. **Set Upstream Branch:** - To track a remote branch, use: - ``` - git branch --set-upstream-to=origin/main main - ``` + 21. **Push with Upstream:** - To push the current branch and set the remote as the upstream branch, use: - ``` - git push --set-upstream origin - ``` + 22. **Tagging:** From 2f1dcf649579e96fc3843e7e8a60cf42cecb8ad6 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:24:27 +0100 Subject: [PATCH 28/75] fixing bugs --- all-notes-from-tutorial.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index b72e4d68..4bb11c01 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -330,7 +330,7 @@ some notes for git learners ``` git push origin master ``` - + - To track a remote branch, use: ``` git branch --set-upstream-to=origin/master master @@ -342,6 +342,7 @@ some notes for git learners ``` **Solving Conflicts** + So, let’s say I pulled the origin, made changes on one of the files. And in the meanwhile, my colleague pulled and did some changes on the same file and pushed the changes. So, it means that the current origin From 66f73241b9ab67788097996b5c8cd7e19cbe5873 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:43:16 +0100 Subject: [PATCH 29/75] Finished Tagging section --- all-notes-from-tutorial.md | 45 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 4bb11c01..0e2a5488 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -5,6 +5,7 @@ some notes for git learners # Git Commands 1. **Initializing a Git Project:** + A repository (or repo) in Git is a storage location where your project's files, along with their entire version history, are stored. It tracks all changes, allowing you to collaborate, revert, and manage versions effectively. To start a new Git repository for your project, use the following command: @@ -342,7 +343,7 @@ some notes for git learners ``` **Solving Conflicts** - + So, let’s say I pulled the origin, made changes on one of the files. And in the meanwhile, my colleague pulled and did some changes on the same file and pushed the changes. So, it means that the current origin @@ -362,59 +363,63 @@ some notes for git learners decide which to keep and which to discard. you can also discard all the signs (\<\<, \>\> and ===) -20. **Set Upstream Branch:** - - - -21. **Push with Upstream:** - - 22. **Tagging:** Tags are used to mark specific points in the commit history. **also you can make versions for your application** - - Show all tags: + - To show all tags: ``` git tag ``` - - Create a tag for the last commit: + - To create a tag for the last commit: + ``` + git tag -a -m "Your message" + ``` + - -a, is to make an annotation, which stores the message, the tagger, the commit author and the dates. + - no need to put the version in the double quotation mark. + + - To create a tag for a specific commit: ``` - git tag -a -m "Your message" + git tag -a -m "Your message" ``` + - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label it. No need to put all the hash, even a few starting characters would work. - - Create a tag for a specific commit: + - To show a version with all the meta related to it (the message, the tagger, the dates and the detail of the last commit before annotating that version): ``` - git tag -a -m "Your message" + git show ``` - - Search between tags (e.g., tags starting with 'v0'): + - To show all the tags starting with 'v0': ``` git tag -l 'v0*' ``` - - Push a specific tag to the remote: + - To push a specific tag to the remote: ``` git push origin ``` - - Push all tags to the remote: + - To push all tags to the remote: ``` git push origin --tags ``` + - tags do not make any changes to the working tree, and nothing will be added on the stage (you can verify this using git status). So, if you just use ```git push origin master```, nothing will be added to the remote. - - Switch to a Tag: + - To switch to a Tag: ``` - git switch + git checkout ``` - - Verify your tag: + - It will take you back to the last commit of this version, however, as the git also tells you, it does not create a separate branch. So, if you make a new commit, this commit will not be made on this version, but it will directly be applied to the original branch you were working on. + + - To verify your tag: ``` git tag -v ``` -23. **GPG Keys and Commit Signing:** +23. **GPG Keys and Signing:** - Show all keys: ``` From d1351d9d0ce7633e354eb279b9d336607bde7c5e Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:48:06 +0100 Subject: [PATCH 30/75] Adding signing section and its intro --- all-notes-from-tutorial.md | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 0e2a5488..21a6b373 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -420,6 +420,66 @@ some notes for git learners ``` 23. **GPG Keys and Signing:** + **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key + cryptography (asymmetric encryption)**, which uses **two mathematically + linked keys**: + + 1. **Public Key (Shared with Others)** + + - Used to **encrypt** messages. + + - Anyone can use it to send you encrypted messages. + + 2. **Private Key (Kept Secret)** + + - Used to **decrypt** messages. + + - Only you can use it to read messages encrypted with your public + key. + + Let’s break it down with a **real-world example**: + + **🔹 Encrypting a Message (Sending Securely)** + + 1. Alice wants to send a **secret** message to Bob. + + 2. She gets **Bob’s public key** (which Bob has shared publicly). + + 3. She **encrypts** the message using Bob’s **public key**. + + 4. Alice sends the **encrypted message** to Bob. + + **🔹 Decrypting a Message (Reading Securely)** + + 1. Bob receives the **encrypted message** from Alice. + + 2. Since the message was encrypted using his **public key**, it can + **only** be decrypted using his **private key**. + + 3. Bob **uses his private key** to decrypt and read the message. + + GP is also used for **digital signatures** to prove identity: + + 1. Bob wants to send an **authentic** message to Alice. + + 2. Bob **signs the message with his private key**. + + 3. Alice **verifies the signature using Bob’s public key** to confirm + it came from him. + + GPG was for commercial and private companies, so GPG has been developed, + using the same principles for open-source use. + + Now, you can digitally **sign** tags and commits in git using GPG, so + full proof your identity, and make every one sure that the commit or tag + is done by you! + + + + + + + - Show all keys: ``` From 52ea72b9f495cc04db7102467946c4cae36e03bd Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:49:31 +0100 Subject: [PATCH 31/75] fixing bugs --- all-notes-from-tutorial.md | 65 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 21a6b373..f864877c 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -420,59 +420,60 @@ some notes for git learners ``` 23. **GPG Keys and Signing:** - **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key - cryptography (asymmetric encryption)**, which uses **two mathematically - linked keys**: - - 1. **Public Key (Shared with Others)** - - Used to **encrypt** messages. + **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key + cryptography (asymmetric encryption)**, which uses **two mathematically + linked keys**: + + 1. **Public Key (Shared with Others)** + + - Used to **encrypt** messages. - - Anyone can use it to send you encrypted messages. + - Anyone can use it to send you encrypted messages. - 2. **Private Key (Kept Secret)** + 2. **Private Key (Kept Secret)** - - Used to **decrypt** messages. + - Used to **decrypt** messages. - - Only you can use it to read messages encrypted with your public - key. + - Only you can use it to read messages encrypted with your public + key. - Let’s break it down with a **real-world example**: + Let’s break it down with a **real-world example**: - **🔹 Encrypting a Message (Sending Securely)** + **🔹 Encrypting a Message (Sending Securely)** - 1. Alice wants to send a **secret** message to Bob. + 1. Alice wants to send a **secret** message to Bob. - 2. She gets **Bob’s public key** (which Bob has shared publicly). + 2. She gets **Bob’s public key** (which Bob has shared publicly). - 3. She **encrypts** the message using Bob’s **public key**. + 3. She **encrypts** the message using Bob’s **public key**. - 4. Alice sends the **encrypted message** to Bob. + 4. Alice sends the **encrypted message** to Bob. - **🔹 Decrypting a Message (Reading Securely)** + **🔹 Decrypting a Message (Reading Securely)** - 1. Bob receives the **encrypted message** from Alice. + 1. Bob receives the **encrypted message** from Alice. - 2. Since the message was encrypted using his **public key**, it can - **only** be decrypted using his **private key**. + 2. Since the message was encrypted using his **public key**, it can + **only** be decrypted using his **private key**. - 3. Bob **uses his private key** to decrypt and read the message. + 3. Bob **uses his private key** to decrypt and read the message. - GP is also used for **digital signatures** to prove identity: + GP is also used for **digital signatures** to prove identity: - 1. Bob wants to send an **authentic** message to Alice. + 1. Bob wants to send an **authentic** message to Alice. - 2. Bob **signs the message with his private key**. + 2. Bob **signs the message with his private key**. - 3. Alice **verifies the signature using Bob’s public key** to confirm - it came from him. + 3. Alice **verifies the signature using Bob’s public key** to confirm + it came from him. - GPG was for commercial and private companies, so GPG has been developed, - using the same principles for open-source use. + GPG was for commercial and private companies, so GPG has been developed, + using the same principles for open-source use. - Now, you can digitally **sign** tags and commits in git using GPG, so - full proof your identity, and make every one sure that the commit or tag - is done by you! + Now, you can digitally **sign** tags and commits in git using GPG, so + full proof your identity, and make every one sure that the commit or tag + is done by you! From afb760db34a67a6940de0d6b5274e539bb47d79c Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:55:33 +0100 Subject: [PATCH 32/75] adding the frst two commands in the signing section --- all-notes-from-tutorial.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index f864877c..65111cb9 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -473,7 +473,27 @@ some notes for git learners Now, you can digitally **sign** tags and commits in git using GPG, so full proof your identity, and make every one sure that the commit or tag - is done by you! + is done by you! Now, How do I make a key? + + - To generate a new key: + ``` + gpg --gen-key + ``` + - Now that you have your key, you give your public key to anyone who wants to see your signatures and keep your private key for signing. + + - To list all your **public keys** in your keyring: + ``` + gpg --list-keys + ``` + - Your public key + allows others to verify your signature. Without your public key, people + can still see your commits/tags, but they can't verify their + authenticity. It ensures that no one else has forged your identity to + push commits under your name. Anyone can set their Git username and + email to pretend to be you: by git config --global user.name "Your Name" + and git config --global user.email . This means someone + can fake commits under your name—but if they don't have your private + key, they can't sign them. From 97d49b00a2da586d095ac552d08f5765041520d2 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:57:54 +0100 Subject: [PATCH 33/75] small adjustments --- all-notes-from-tutorial.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 65111cb9..428a33c1 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -485,15 +485,7 @@ some notes for git learners ``` gpg --list-keys ``` - - Your public key - allows others to verify your signature. Without your public key, people - can still see your commits/tags, but they can't verify their - authenticity. It ensures that no one else has forged your identity to - push commits under your name. Anyone can set their Git username and - email to pretend to be you: by git config --global user.name "Your Name" - and git config --global user.email . This means someone - can fake commits under your name—but if they don't have your private - key, they can't sign them. + - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name—but if they don't have your private key, they can't sign them. From 54561f5f7028171b2ef18e8bf84f8c5f3b5fe828 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:48:37 +0100 Subject: [PATCH 34/75] writting the description of a private key --- all-notes-from-tutorial.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 428a33c1..4990da68 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -486,6 +486,27 @@ some notes for git learners gpg --list-keys ``` - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name—but if they don't have your private key, they can't sign them. + + - To list all your **private (secret) keys** in your keyring: + ``` + gpg --list-secret-keys --keyid-format LONG + ``` + - This is your signing key. You’ll get something like this: the highlighted part is your key. + + output example: + > \[keyboxd\] + > + > --------- + > + > sec ed25519/51D5C682AB1A7B0C 2025-02-13 + > \[SC\] \[expires: 2028-02-13\] + > + > CC22A2B6C514DB471260321E51D5C682AB1A7B0C + > + > uid \[ultimate\] Jalal Abbasi \ + > + > ssb cv25519/678FBAE76D47A781 2025-02-13 \[E\] \[expires: 2028-02-13\] + From f9025ee6c751202c7fd791c4dd9f763b1f3ac884 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:51:51 +0100 Subject: [PATCH 35/75] highlighting the private key --- all-notes-from-tutorial.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 4990da68..beaf6a89 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -493,12 +493,10 @@ some notes for git learners ``` - This is your signing key. You’ll get something like this: the highlighted part is your key. - output example: - > \[keyboxd\] - > - > --------- + output example: The highlighted part is your private key. + > - > sec ed25519/51D5C682AB1A7B0C 2025-02-13 + > sec ed25519/'51D5C682AB1A7B0C' 2025-02-13 > \[SC\] \[expires: 2028-02-13\] > > CC22A2B6C514DB471260321E51D5C682AB1A7B0C From 3c51a66a4456059ab60bd6050644cd15ede979cf Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:53:13 +0100 Subject: [PATCH 36/75] fixing a bug --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index beaf6a89..18fc472c 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -496,7 +496,7 @@ some notes for git learners output example: The highlighted part is your private key. > - > sec ed25519/'51D5C682AB1A7B0C' 2025-02-13 + > sec ed25519/`51D5C682AB1A7B0C` 2025-02-13 > \[SC\] \[expires: 2028-02-13\] > > CC22A2B6C514DB471260321E51D5C682AB1A7B0C From 5ff2a8f877efbdb60516bf8850729c02833bf0fb Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:09:09 +0100 Subject: [PATCH 37/75] Finishing the signature part --- all-notes-from-tutorial.md | 62 +++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 18fc472c..a5144af4 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -505,6 +505,59 @@ some notes for git learners > > ssb cv25519/678FBAE76D47A781 2025-02-13 \[E\] \[expires: 2028-02-13\] + - To show your private signing key: + ``` + git config --global user.signingkey + ``` + - if you have not set any yet in git, it does not show anything. + + - Set your signing key for the current user across all repositories: + ``` + git config --global user.signingKey 'your-secret-key' + ``` + + - To tag the last commit with your signature: + ``` + git tag -s -m “message” + ``` + + - To commit with your signature: + ``` + git commit -S -m “message” + ``` + - if you use git log, it does not show if it is signed or not. + + - To verify if the is signed: + ``` + git tag -v + ``` + - -v here means to verify (do not mistake it with "verbous") + - if verified, you’ll get a message like: Good signature from "Jalal Abbasi " [ultimate] + + - To see the excact signature characters as a part of tag message: + ``` + git show + ``` + - It is a code between two lines, as below: + >-----BEGIN PGP SIGNATURE----- + > + >iHUEABYKAB0WIQTMIqK2xRTbRxJgMh5R1caCqxp7DAUCZ65O2wAKCRBR1caCqxp7 + > + >DCIOAQCgjUvfc/cyJc7dlZxhtlJwSBj270Cu+1HXPIIhaLSpYQD+J9FXuqfwUUqK + > + >nWWqA7pTgfPWzNeJNPqujussqPns1gA= + > + >=/A/w + > + >-----END PGP SIGNATURE----- + + + + + + + + @@ -525,14 +578,7 @@ some notes for git learners ``` gpg --list-secret-keys --keyid-format LONG ``` - - Set your signing key for this project: - ``` - git config user.signingKey 'your-secret-key' - ``` - - Show your signing key for this project: - ``` - git config user.signingKey - ``` + - Set a global signing key for all projects: ``` From 0e2bdb325c7960e9a81d7f6fe0889040f87290ab Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:17:18 +0100 Subject: [PATCH 38/75] Describing blame --- all-notes-from-tutorial.md | 63 ++++++++------------------------------ 1 file changed, 12 insertions(+), 51 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index a5144af4..1ad30ae8 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -552,65 +552,26 @@ some notes for git learners >-----END PGP SIGNATURE----- +24. **Debugging using Git:** - - - - - - - - - - - - - - - Show all keys: - ``` - gpg --list-keys - ``` - - Generate a new key: - ``` - gpg --gen-key - ``` - - Show my secret keys: + - To show all the change history about your file: ``` - gpg --list-secret-keys --keyid-format LONG - ``` - - - - Set a global signing key for all projects: - ``` - git config user.signingKey 'your-secret-key' --global - ``` - - - Sign your version/tag: - ``` - git tag -s 'version-number' -m "your-message" + git blame ``` - - - Sign your commit: + - It shows who have written which part of this +last code and when. + - To show all the change history about your requested line in the requested file: ``` - git commit -S -m 'your-message' + git blame -Ln ``` - - - Verify your tag: + - It shows, who has written the code in line “n”, in the , in a chronological order, from the latest to the oldest. + - To show the last person who has modified the code between lines n and m and the date he/she modified them: ``` - git tag -v 'tag-name or version-number' + git blame -Ln,m ``` + - Git Blame is useful for tracing the changes made to a file. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. -24. **Blame History:** - - - Show all the change history about your file: - ``` - git blame - ``` - - Show all the change history about your requested line in the requested file: - ``` - git blame -L5 - ``` - - Git Blame is useful for tracing the changes made to a file, and using the `-L` parameter, you can specify a specific line range to investigate. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. + Remember to use these commands as needed in your Git projects. It's important to maintain a clean and organized version control process for effective collaboration and project management. From da53cf2f6b77c31e023e6065774d48269a0ef9ee Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:20:23 +0100 Subject: [PATCH 39/75] Adding the Bisect description --- all-notes-from-tutorial.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 1ad30ae8..fe178f56 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -558,8 +558,7 @@ some notes for git learners ``` git blame ``` - - It shows who have written which part of this -last code and when. + - It shows who have written which part of this last code and when. - To show all the change history about your requested line in the requested file: ``` git blame -Ln @@ -570,6 +569,37 @@ last code and when. git blame -Ln,m ``` - Git Blame is useful for tracing the changes made to a file. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. + + **Bisect** + + (binary-search-commits): so, you are in the latest commit, and you have + a bug in your code and you want to find it, git helps you to find it in + an iterative way. + + So first you must go the highest level of the directory. Then you tell + git to start the process. Then you tell the latest commit is bad. Then + ask you to determine what was the latest commit in the history, that was + working fine. Given these two commits, the git goes and find the commit + between these two, and asks you to check if it is good or bad. If it is + good, it means that the bug is present between this middle commit and + the latest one, and if not, it means that the bug is present between + this middle commit and that last good commit. + + 1. ```git bisect start``: telling git to start the bisect. + + 2. ```git bisect bad```: telling the git that the commit that we are now at + it, so the latest one, is bad (buggy). + + 3. ```git bisect good ```: then we have to tell the git the + last commit in the log, in which the code was working well. + + 4. ITERATIVE: then git gives you a commit hash and asks you to check if + it is good or bad. If good, you write git bisect good, else you + write git bisect bad. Then, git now checks again, between the commit + it mentioned you, and the last or the last good commit, according to + your answer, and gives you another commit to check. Then this + iteration goes on this way. + From a47e03303f430431273dc3fcf723943bceb60ca1 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:21:12 +0100 Subject: [PATCH 40/75] bug fix --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index fe178f56..c2874480 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -570,7 +570,7 @@ some notes for git learners ``` - Git Blame is useful for tracing the changes made to a file. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. - **Bisect** + **Bisect** (binary-search-commits): so, you are in the latest commit, and you have a bug in your code and you want to find it, git helps you to find it in From 3e787c1b7c3ff2d0b8d0db06a6712e8816b4c4e9 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:24:05 +0100 Subject: [PATCH 41/75] Adding section: Forking --- all-notes-from-tutorial.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index c2874480..1078dc7c 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -364,7 +364,7 @@ some notes for git learners the signs (\<\<, \>\> and ===) -22. **Tagging:** +12. **Tagging:** Tags are used to mark specific points in the commit history. **also you can make versions for your application** @@ -419,7 +419,7 @@ some notes for git learners git tag -v ``` -23. **GPG Keys and Signing:** +13. **GPG Keys and Signing:** **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key cryptography (asymmetric encryption)**, which uses **two mathematically @@ -552,7 +552,7 @@ some notes for git learners >-----END PGP SIGNATURE----- -24. **Debugging using Git:** +14. **Debugging using Git:** - To show all the change history about your file: ``` @@ -585,7 +585,7 @@ some notes for git learners the latest one, and if not, it means that the bug is present between this middle commit and that last good commit. - 1. ```git bisect start``: telling git to start the bisect. + 1. ```git bisect start```: telling git to start the bisect. 2. ```git bisect bad```: telling the git that the commit that we are now at it, so the latest one, is bad (buggy). @@ -600,6 +600,18 @@ some notes for git learners your answer, and gives you another commit to check. Then this iteration goes on this way. +15. **Forking and Pull (Merge) Request:** + + let’s say someone has a repository in their Github or Gitlab profile. + Forking means making a copy of their project and placing it on your + repository tab, so that you can work on it separately. So, you clone + this forked project and work on it on your local machine and make some + changes to it. Then, you push these changes to your own forked project. + If you want to notify the guy who originally made the project about your + changes and ask him if he wants to merge these changes also to his own + project, you send him a pull request (in Github) or merge request (in + Gitlab). the Guy will check your changes and decides whether to accept + this merge or not.** From fbcebb4664f6dc61a479a67f51e7bffd163fde7e Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:25:20 +0100 Subject: [PATCH 42/75] fixing a bug --- all-notes-from-tutorial.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 1078dc7c..b76afd85 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -601,17 +601,16 @@ some notes for git learners iteration goes on this way. 15. **Forking and Pull (Merge) Request:** - - let’s say someone has a repository in their Github or Gitlab profile. - Forking means making a copy of their project and placing it on your - repository tab, so that you can work on it separately. So, you clone - this forked project and work on it on your local machine and make some - changes to it. Then, you push these changes to your own forked project. - If you want to notify the guy who originally made the project about your - changes and ask him if he wants to merge these changes also to his own - project, you send him a pull request (in Github) or merge request (in - Gitlab). the Guy will check your changes and decides whether to accept - this merge or not.** + let’s say someone has a repository in their Github or Gitlab profile. + Forking means making a copy of their project and placing it on your + repository tab, so that you can work on it separately. So, you clone + this forked project and work on it on your local machine and make some + changes to it. Then, you push these changes to your own forked project. + If you want to notify the guy who originally made the project about your + changes and ask him if he wants to merge these changes also to his own + project, you send him a pull request (in Github) or merge request (in + Gitlab). the Guy will check your changes and decides whether to accept + this merge or not.** From c899d127e1a4c6799839dff56a4a03db1e5607a4 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:32:20 +0100 Subject: [PATCH 43/75] Adding Other git commands section --- all-notes-from-tutorial.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index b76afd85..2444b28d 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -552,7 +552,7 @@ some notes for git learners >-----END PGP SIGNATURE----- -14. **Debugging using Git:** +14. **Debugging Using Git:** - To show all the change history about your file: ``` @@ -601,6 +601,7 @@ some notes for git learners iteration goes on this way. 15. **Forking and Pull (Merge) Request:** + let’s say someone has a repository in their Github or Gitlab profile. Forking means making a copy of their project and placing it on your repository tab, so that you can work on it separately. So, you clone @@ -612,6 +613,33 @@ some notes for git learners Gitlab). the Guy will check your changes and decides whether to accept this merge or not.** +16. **Other Git Commands:** + - Differences in using "--": + 1.```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files + 2.```-- ```: name is a file name: like ```git checkout -- page1.html``` + + - To configure git settings on three levels: + ``` + git config --system/--global/--local + ``` + + | **Level** | **Scope** | **Location** | + |----|----|----| + | **System** | Applies to all users on the system | /etc/gitconfig | + | **Global** | Applies to your user across all repos | ~/.gitconfig or ~/.config/git/config | + | **Local** | Applies only to the specific repository | .git/config inside the repo | + + - To ask for your system user: + ``` + git config --global user.name + ``` + + - To you git help: + ``` + git help + ``` + + Remember to use these commands as needed in your Git projects. It's important to maintain a clean and organized version From c0bfe89c5decfe662b1dbf682607e214aef48caf Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:33:09 +0100 Subject: [PATCH 44/75] bug fix --- all-notes-from-tutorial.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 2444b28d..bde44b21 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -615,7 +615,9 @@ some notes for git learners 16. **Other Git Commands:** - Differences in using "--": + 1.```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files + 2.```-- ```: name is a file name: like ```git checkout -- page1.html``` - To configure git settings on three levels: From 68f197ea9b7f66d80b89c007717451072f308a1d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:40:46 +0100 Subject: [PATCH 45/75] Adding section: Unix-Specific Commands --- all-notes-from-tutorial.md | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index bde44b21..16b1577d 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -616,9 +616,9 @@ some notes for git learners 16. **Other Git Commands:** - Differences in using "--": - 1.```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files - - 2.```-- ```: name is a file name: like ```git checkout -- page1.html``` + 1. ```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files + + 2. ```-- ```: name is a file name: like ```git checkout -- page1.html``` - To configure git settings on three levels: ``` @@ -641,6 +641,54 @@ some notes for git learners git help ``` +17. **Unix-Specific Commands** + + - ```touch ``` : To create an empty file (any type: text, html, etc) on the Git bash. + + - ```diff```: Shows the differences made in the current file + + - ```cat ```: Shows the content of the file (cat stands for concatenate) + + - ```cat file1.txt file2.txt > combined.txt```: This will **combine** file1.txt and file2.txt into a new file called combined.txt. + + - ```cat > newfile.txt```: This allows you to **create and write** to a new + file. After running the command, you can type your content, and press + Ctrl+D to save and exit. + + - ```~```: Refers to your home directory in Git Bash (C:\Users\YourUsername) + + - ```vi ```: To edit a file in vim text editor, or create a new one is does not + exist: + + **Vim text editor**: + It is a widely used **text editor** available in almost all **Unix-based environments**, including **Linux, macOS, and BSD**. + + Here’s a compact table of basic Vi (Vim) commands: + + | **Mode** | **Command** | **Action** | + |-----------------|-------------|-----------------------------| + | **Insert Mode** | i | Insert at cursor | + | | a | Append after cursor | + | | o | Open a new line below | + | **Exit & Save** | Esc → :wq | Save and exit | + | | Esc → :x | Save and exit (same as :wq) | + | | Esc → :q! | Quit without saving | + | | Esc → :w | Save without quitting | + | **Navigation** | h | Move left | + | | l | Move right | + | | j | Move down | + | | k | Move up | + | | gg | Go to first line | + | | G | Go to last line | + | **Editing** | dd | Delete current line | + | | yy | Copy (yank) current line | + | | p | Paste after cursor | + | **Search** | /text | Search for "text" | + | | n | Jump to next match | + | | N | Jump to previous match | + | **Undo/Redo** | u | Undo last change | + | | Ctrl + r | Redo last undo | + From b798e7c5e5678e1d226647dcfbcf93b7868c13d5 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:42:43 +0100 Subject: [PATCH 46/75] Fixing bugs --- all-notes-from-tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 16b1577d..a0fa1bde 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -647,7 +647,7 @@ some notes for git learners - ```diff```: Shows the differences made in the current file - - ```cat ```: Shows the content of the file (cat stands for concatenate) + - ```cat filename.txt```: Shows the content of the file (cat stands for concatenate) - ```cat file1.txt file2.txt > combined.txt```: This will **combine** file1.txt and file2.txt into a new file called combined.txt. @@ -657,7 +657,7 @@ some notes for git learners - ```~```: Refers to your home directory in Git Bash (C:\Users\YourUsername) - - ```vi ```: To edit a file in vim text editor, or create a new one is does not + - ```vi ```: To edit a file in Vim text editor, or create a new one is does not exist: **Vim text editor**: From 2bbe6959749e8f09a84de54172fe83851f62851d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:59:48 +0100 Subject: [PATCH 47/75] Fixing bugs --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index a0fa1bde..47be458d 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -383,7 +383,7 @@ some notes for git learners - To create a tag for a specific commit: ``` - git tag -a -m "Your message" + git tag -a -m "Your message" ``` - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label it. No need to put all the hash, even a few starting characters would work. From fa7c9b0f87671ecfb67789a626ef8cbc2a8de472 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:13:37 +0100 Subject: [PATCH 48/75] changing numbers to sections --- all-notes-from-tutorial.md | 51 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 47be458d..ca5cee58 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -1,10 +1,19 @@ -# git-learning-notes +Github Onramp by jadi: Summary of the notes and commands -some notes for git learners +# Table of Contents + - [Initializing a Git Project](#Initializing-a-Git-Project) + - [Checking Git Status](#Checking-Git-Status) + - [Report Commands](#report-commands) + - [File Modification](#file-modification) + - [Branches](#branches) + - [Git In The Cloud !](#git-in-the-cloud) + - [Conflicts](#conflicts) + - [Tags](#tags) + - [Sign Commites And Tags](#sign-commites-and-tags) + - [Debug With Git](#debug-with-git) -# Git Commands -1. **Initializing a Git Project:** +# Initializing a Git Project A repository (or repo) in Git is a storage location where your project's files, along with their entire version history, are stored. It tracks all changes, allowing you to collaborate, revert, and manage versions effectively. @@ -17,7 +26,7 @@ some notes for git learners - Used when starting a new project or making an existing directory a Git repository. -2. **Checking the Status:** +# Checking Git Status - To view the current status of your local repository: ``` @@ -34,7 +43,7 @@ some notes for git learners git show ``` -3. **Adding Files to the Staging Area:** +# Adding Files to the Staging Area To Add files to the staging area to prepare them for commit. You have several options: @@ -63,13 +72,13 @@ some notes for git learners git add “hello*” ``` - -4. **Removing a file from the local repository:** +# Removing a file from the local repository To remove a file from Git and your project, use: ``` git rm 'file-name' ``` -5. **Committing Changes:** + +# Committing Changes To save the staged changes as a new snapshot, use the `git commit` command: ``` @@ -78,7 +87,7 @@ some notes for git learners - `git commit`: You can also write this command (without adding -m "comment") and insert your comment in the editor. - Always include a comment with your commit. -6. **Viewing Differences:** +# Viewing Differences Git provides several ways to view differences: @@ -140,7 +149,7 @@ some notes for git learners -7. **Reseting and Exiting the Staging Area:** +# Reseting and Exiting the Staging Area To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` command: @@ -157,7 +166,7 @@ some notes for git learners git reset --hard ``` -8. **Restoring Files:** +# Restoring Files To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: @@ -196,7 +205,7 @@ some notes for git learners - `'--'`: Refers to the HEAD (latest commit). -9. **Working With Branches:** +# Working With Branches When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: @@ -249,7 +258,7 @@ some notes for git learners - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. -10. **Cloning a Remote Repository** +# Cloning a Remote Repository** Remote is a reference to a repository on a server, like github or gitlab, or even another machine. If you clone a repository from @@ -295,7 +304,7 @@ some notes for git learners (which -u stands for --set-upstream). the next time you want to do the same thing, you only need to write `git push`. -11. **Adding a Remote Repository:** +# Adding a Remote Repository - To link a remote address to your current project on your local machine, use: ``` @@ -364,7 +373,7 @@ some notes for git learners the signs (\<\<, \>\> and ===) -12. **Tagging:** +# Tagging Tags are used to mark specific points in the commit history. **also you can make versions for your application** @@ -419,7 +428,7 @@ some notes for git learners git tag -v ``` -13. **GPG Keys and Signing:** +# GPG Keys and Signing **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key cryptography (asymmetric encryption)**, which uses **two mathematically @@ -552,7 +561,7 @@ some notes for git learners >-----END PGP SIGNATURE----- -14. **Debugging Using Git:** +# Debugging Using Git - To show all the change history about your file: ``` @@ -600,7 +609,7 @@ some notes for git learners your answer, and gives you another commit to check. Then this iteration goes on this way. -15. **Forking and Pull (Merge) Request:** +# Forking and Pull (Merge) Request let’s say someone has a repository in their Github or Gitlab profile. Forking means making a copy of their project and placing it on your @@ -613,7 +622,7 @@ some notes for git learners Gitlab). the Guy will check your changes and decides whether to accept this merge or not.** -16. **Other Git Commands:** +# Other Git Commands - Differences in using "--": 1. ```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files @@ -641,7 +650,7 @@ some notes for git learners git help ``` -17. **Unix-Specific Commands** +# Unix-Specific Commands - ```touch ``` : To create an empty file (any type: text, html, etc) on the Git bash. From 55c9ce44b495604cc4d8a15cf5c5e86da181aa7a Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:23:27 +0100 Subject: [PATCH 49/75] completing the table of contents --- all-notes-from-tutorial.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index ca5cee58..f64dce65 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -1,16 +1,23 @@ -Github Onramp by jadi: Summary of the notes and commands +Github Onramp course by jadi: Summary of the notes and commands # Table of Contents - [Initializing a Git Project](#Initializing-a-Git-Project) - [Checking Git Status](#Checking-Git-Status) - - [Report Commands](#report-commands) - - [File Modification](#file-modification) - - [Branches](#branches) - - [Git In The Cloud !](#git-in-the-cloud) - - [Conflicts](#conflicts) - - [Tags](#tags) - - [Sign Commites And Tags](#sign-commites-and-tags) - - [Debug With Git](#debug-with-git) + - [Adding Files to the Staging Area](#Adding-Files-to-the-Staging-Area) + - [Removing a file from the local repository](#Removing-a-file-from-the-local-repository) + - [Committing Changes](#Committing-Changes) + - [Viewing Differences](#Viewing-Differences) + - [Reseting and Exiting the Staging Area](#Reseting-and-Exiting-the-Staging-Area) + - [Restoring Files](#Restoring-Files) + - [Working With Branches](#Working-With-Branches) + - [Cloning a Remote Repository](#Cloning-a-Remote-Repository) + - [Adding a Remote Repository](#Adding-a-Remote-Repository) + - [Tagging](#tagging) + - [GPG Keys and Signing](#gpg-keys-and-signing) + - [Debugging Using Git](#debugging-using-git) + - [Forking and Pull (Merge) Request](#forking-and-pull-merge-request) + - [Other Git Commands](#other-git-commands) + - [Unix-Specific Commands](#unix-specific-commands) # Initializing a Git Project @@ -258,7 +265,7 @@ Github Onramp by jadi: Summary of the notes and commands - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. -# Cloning a Remote Repository** +# Cloning a Remote Repository Remote is a reference to a repository on a server, like github or gitlab, or even another machine. If you clone a repository from From 024a5c0a558e8bf5c80fa5bcc8be89e25efffb04 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:24:41 +0100 Subject: [PATCH 50/75] adding the staging layer table to the git status section --- all-notes-from-tutorial.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index f64dce65..42c3e460 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -35,6 +35,14 @@ Github Onramp course by jadi: Summary of the notes and commands # Checking Git Status + **The 4 Storage Layers in Git** + | **Level** | **Where It Lives** | **Purpose** | + |----|----|----| + | **Working Directory** | Your actual files | Where you edit code | + | **Staging Area (index)** | .git/index | Prepares specific changes for commit | + | **Commit History** | .git/objects/ | Saves permanent snapshots of code | + | **Remote (Push)** | GitHub, GitLab, etc. | Shares commits with others | + - To view the current status of your local repository: ``` git status From 7c28f739f04ec098fed5217c01e3d838a33e5b9e Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:25:56 +0100 Subject: [PATCH 51/75] fixing bugs --- all-notes-from-tutorial.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 42c3e460..79e2810d 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -22,16 +22,16 @@ Github Onramp course by jadi: Summary of the notes and commands # Initializing a Git Project - A repository (or repo) in Git is a storage location where your project's files, along with their entire version history, are stored. It tracks all changes, allowing you to collaborate, revert, and manage versions effectively. - - To start a new Git repository for your project, use the following command: - ``` - git init - ``` - - It creates a hidden .git folder, which stores all the repository’s - metadata (branches, commits, configurations, etc.). - - Used when starting a new project or making an existing directory a Git - repository. + A repository (or repo) in Git is a storage location where your project's files, along with their entire version history, are stored. It tracks all changes, allowing you to collaborate, revert, and manage versions effectively. + + To start a new Git repository for your project, use the following command: + ``` + git init + ``` + - It creates a hidden .git folder, which stores all the repository’s + metadata (branches, commits, configurations, etc.). + - Used when starting a new project or making an existing directory a Git + repository. # Checking Git Status From 92cd93fccef1c16015e0e49f60ddfbd3ae4ca392 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:29:17 +0100 Subject: [PATCH 52/75] fixing bugs --- all-notes-from-tutorial.md | 1062 ++++++++++++++++++------------------ 1 file changed, 531 insertions(+), 531 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 79e2810d..7a17d285 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -60,658 +60,658 @@ Github Onramp course by jadi: Summary of the notes and commands # Adding Files to the Staging Area - To Add files to the staging area to prepare them for commit. You have several options: + To Add files to the staging area to prepare them for commit. You have several options: - - To add all (the changed) files: - ``` - git add -A - ``` - - - To add specific file types, e.g., all HTML files: - ``` - git add "*.html" - ``` - - - To add a specific file : - ``` - git add - ``` + - To add all (the changed) files: + ``` + git add -A + ``` + + - To add specific file types, e.g., all HTML files: + ``` + git add "*.html" + ``` - - To add more than one file at the same time: - ``` - git add “file1.txt” “file2.txt” - ``` + - To add a specific file : + ``` + git add + ``` - - To add any file that has "hello" in its name: - ``` - git add “hello*” - ``` + - To add more than one file at the same time: + ``` + git add “file1.txt” “file2.txt” + ``` -# Removing a file from the local repository - To remove a file from Git and your project, use: + - To add any file that has "hello" in its name: ``` - git rm 'file-name' + git add “hello*” ``` +# Removing a file from the local repository + To remove a file from Git and your project, use: + ``` + git rm 'file-name' + ``` + # Committing Changes - To save the staged changes as a new snapshot, use the `git commit` command: - ``` - git commit -m "Your comment about the changes" - ``` - - `git commit`: You can also write this command (without adding -m "comment") and insert your comment in the editor. - - Always include a comment with your commit. + To save the staged changes as a new snapshot, use the `git commit` command: + ``` + git commit -m "Your comment about the changes" + ``` + - `git commit`: You can also write this command (without adding -m "comment") and insert your comment in the editor. + - Always include a comment with your commit. # Viewing Differences - Git provides several ways to view differences: - - - See the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. - ``` - git diff HEAD - ``` - - HEAD: is a special pointer that refers to the current branch's latest commit. However, the location of this pointer can be changed to any commit you want. + Git provides several ways to view differences: - - See the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. - ``` - git diff --staged - ``` + - See the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. + ``` + git diff HEAD + ``` + - HEAD: is a special pointer that refers to the current branch's latest commit. However, the location of this pointer can be changed to any commit you want. - Example: + - See the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. + ``` + git diff --staged + ``` - I make one change in the pag1.html, then add it to the stage then make - another change, without adding: - - - - - - - - - - - - - - - - - - -
$ git diff HEAD$ git diff --staged

diff --git a/page1.html b/page1.html

-

index d637411..b11a95a 100644

-

--- a/page1.html

-

+++ b/page1.html

-

@@ -2,5 +2,7 @@

-

<body>

-

project 1!

-

Hi there!

-

+ I am Jalal.

-

+ I love programming!

-

<html>

-

<body>

-

\ No newline at end of file

diff --git a/page1.html b/page1.html

-

index d637411..b2f8fc6 100644

-

--- a/page1.html

-

+++ b/page1.html

-

@@ -2,5 +2,6 @@

-

<body>

-

project 1!

-

Hi there!

-

+ I am Jalal.

-

<html>

-

<body>

-

\ No newline at end of file

+ Example: + + I make one change in the pag1.html, then add it to the stage then make + another change, without adding: + + + + + + + + + + + + + + + + + + +
$ git diff HEAD$ git diff --staged

diff --git a/page1.html b/page1.html

+

index d637411..b11a95a 100644

+

--- a/page1.html

+

+++ b/page1.html

+

@@ -2,5 +2,7 @@

+

<body>

+

project 1!

+

Hi there!

+

+ I am Jalal.

+

+ I love programming!

+

<html>

+

<body>

+

\ No newline at end of file

diff --git a/page1.html b/page1.html

+

index d637411..b2f8fc6 100644

+

--- a/page1.html

+

+++ b/page1.html

+

@@ -2,5 +2,6 @@

+

<body>

+

project 1!

+

Hi there!

+

+ I am Jalal.

+

<html>

+

<body>

+

\ No newline at end of file

# Reseting and Exiting the Staging Area - To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` - command: + To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` + command: - - To unstage a file, use: - ``` - git reset - ``` + - To unstage a file, use: + ``` + git reset + ``` - - To move the HEAD pointer to a specific commit and optionally modify the staging area and working directory, use: - ``` - git reset --soft - git reset --mixed - git reset --hard - ``` + - To move the HEAD pointer to a specific commit and optionally modify the staging area and working directory, use: + ``` + git reset --soft + git reset --mixed + git reset --hard + ``` # Restoring Files - To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: + To manipulate the state of your working directory and staging area without affecting the commit history, you can use the `git restore` command: - - To unstage a file, use: - ``` - git restore --staged - ``` - - it works similarly to the `(git reset )` command. + - To unstage a file, use: + ``` + git restore --staged + ``` + - it works similarly to the `(git reset )` command. - - To restore all staged files: - ``` - git restore --staged * - ``` + - To restore all staged files: + ``` + git restore --staged * + ``` - - To restore file content back to latest commit: - ``` - git restore - ``` + - To restore file content back to latest commit: + ``` + git restore + ``` - - To restore a specific file from a previous commit to your working directory, use: - ``` - git restore --source= - ``` - - It restores the content of to match the version from the specified . This will overwrite the file in your working directory with the version from the given commit, but it won't affect the staging area or commit history. + - To restore a specific file from a previous commit to your working directory, use: + ``` + git restore --source= + ``` + - It restores the content of to match the version from the specified . This will overwrite the file in your working directory with the version from the given commit, but it won't affect the staging area or commit history. - - To restore your entire working directory to match a specific commit, use: - ``` - git restore --source= . - ``` - - - To replace a file with the version from the HEAD (latest commit), use: - ``` - git checkout -- - ``` - - if you have not yet committed the changes, it will undo all changes and brings the file back to the previous commit file status. So, it restores all the changes back to the latest commit. - - `'--'`: Refers to the HEAD (latest commit). + - To restore your entire working directory to match a specific commit, use: + ``` + git restore --source= . + ``` + + - To replace a file with the version from the HEAD (latest commit), use: + ``` + git checkout -- + ``` + - if you have not yet committed the changes, it will undo all changes and brings the file back to the previous commit file status. So, it restores all the changes back to the latest commit. + - `'--'`: Refers to the HEAD (latest commit). # Working With Branches - When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: + When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - - To show all branches in the project: - ``` - git branch - ``` - - The output highlights your current working branch with an astrix (\*). - Example: - > \$ git branch - > - > fixhtml - > - > \* master - - - To Create a new branch for your project: - ``` - git branch 'branch-name' - ``` + - To show all branches in the project: + ``` + git branch + ``` + - The output highlights your current working branch with an astrix (\*). + Example: + > \$ git branch + > + > fixhtml + > + > \* master - - To delete a branch from the project: - ``` - git branch -d 'branch-name' - ``` + - To Create a new branch for your project: + ``` + git branch 'branch-name' + ``` - - To switch to a different branch and replace all the files in your current branch with those from 'branch-name', - use: - ``` - git checkout 'branch-name' - ``` - - so, let’s say you make a new branch and go to this branch, make some files and change the contents of the other. If you switch back the master using checkout, all the files and changes that you have made will disappear from your computer directory! + - To delete a branch from the project: + ``` + git branch -d 'branch-name' + ``` - - To merge a branch into your current branch, use: - ``` - git merge 'branch-name' - ``` - - it merges the changes you made in the new branch on the branch master. note that before using this command you have to checkout first to the branch master. - - When you switch from one branch to the other (let’s say from master to a new branch named "linkingpages") the git bash interface will show a message, telling you what is different in your working directory compared to linkingpages after switching. D means deleted, and M means modified. - In this example, one file has been modified and one has been deleted, comparing the branch content with the working directory: - - > \$ git checkout linkingpages - > - > D 2_project.html - > - > M Git init.docx - > - > D index.txt - > - > Switched to branch 'linkingpages' - - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. - - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. + - To switch to a different branch and replace all the files in your current branch with those from 'branch-name', + use: + ``` + git checkout 'branch-name' + ``` + - so, let’s say you make a new branch and go to this branch, make some files and change the contents of the other. If you switch back the master using checkout, all the files and changes that you have made will disappear from your computer directory! + + - To merge a branch into your current branch, use: + ``` + git merge 'branch-name' + ``` + - it merges the changes you made in the new branch on the branch master. note that before using this command you have to checkout first to the branch master. + - When you switch from one branch to the other (let’s say from master to a new branch named "linkingpages") the git bash interface will show a message, telling you what is different in your working directory compared to linkingpages after switching. D means deleted, and M means modified. + In this example, one file has been modified and one has been deleted, comparing the branch content with the working directory: + + > \$ git checkout linkingpages + > + > D 2_project.html + > + > M Git init.docx + > + > D index.txt + > + > Switched to branch 'linkingpages' + - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. + - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. # Cloning a Remote Repository - Remote is a reference to a repository on a server, like github or - gitlab, or even another machine. If you clone a repository from - GitHub, Git automatically creates a remote reference called origin. - - Origin is the default name given to a remote repository when you - clone a project. It acts as a shortcut to refer to the original - repository's URL, so you don’t have to type the full address every - time. - - In Git, a **remote is a reference** because it's essentially a - **pointer** or **label** that Git uses to keep track of where a - repository is located. So, a **remote** is a **reference to the - location of a repository**—this **location** can be a URL, and Git - uses that reference to fetch and push data. Technically speaking, Git stores remotes as **configuration entries** in your repository. So, remote is a **configuration entry** stored as plain text in the Git configuration file. Git keeps this information in a special file called .git/config in your local repository. - For example, a typical section in .git/config looks like this: - > \[remote "origin"\] - > - > url = https://github.com/user/repo.git - > - > fetch = +refs/heads/\*:refs/remotes/origin/\* - > - This configuration section is where **origin** is the reference, and - the **URL** (https://github.com/user/repo.git) is the data that Git - uses to access the remote repository. - - - Clonning a project means making a copy of a remote project from a remote location (like GitHub) on your local directory. To do so we use this command: - ``` - git clone - ``` - - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This in Git terminology is called "pulling". We pull the file from the origin and write them on the master branch: - ``` - git pull origin master - ``` - - If you made some changes on your local repository, and want to send committed changes from your local repository to the remote server (usually in the cloud, like GitHub or GitLab), you "push" these changes from your master brach to the origin by: - ``` - git push origin master - ``` - - if you want to tell Git, to make this push path (from master branch to the origin), as a default pushing path, you need to first write: - ``` - git push -u origin master - ``` - (which -u stands for --set-upstream). the next time you want to do the same thing, you only - need to write `git push`. + Remote is a reference to a repository on a server, like github or + gitlab, or even another machine. If you clone a repository from + GitHub, Git automatically creates a remote reference called origin. -# Adding a Remote Repository + Origin is the default name given to a remote repository when you + clone a project. It acts as a shortcut to refer to the original + repository's URL, so you don’t have to type the full address every + time. - - To link a remote address to your current project on your local machine, use: - ``` - git remote add origin - ``` - - For starting a project, you make an empty repository on the cloud and link it to your local repository, to save and push files also on the cloud. - - You can add multiple remotes to your projects and push them into different repositories at the same time for increased safety. - - Origin is the default remote name. You can replace the origin with any name you want in this command. + In Git, a **remote is a reference** because it's essentially a + **pointer** or **label** that Git uses to keep track of where a + repository is located. So, a **remote** is a **reference to the + location of a repository**—this **location** can be a URL, and Git + uses that reference to fetch and push data. Technically speaking, Git stores remotes as **configuration entries** in your repository. So, remote is a **configuration entry** stored as plain text in the Git configuration file. Git keeps this information in a special file called .git/config in your local repository. + For example, a typical section in .git/config looks like this: + > \[remote "origin"\] + > + > url = https://github.com/user/repo.git + > + > fetch = +refs/heads/\*:refs/remotes/origin/\* + > + This configuration section is where **origin** is the reference, and + the **URL** (https://github.com/user/repo.git) is the data that Git + uses to access the remote repository. - - To view the remotes attached to your local repository: + - Clonning a project means making a copy of a remote project from a remote location (like GitHub) on your local directory. To do so we use this command: ``` - git remote + git clone ``` - - - To make the output of the previous command (-v stands for "verbous"): + - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This in Git terminology is called "pulling". We pull the file from the origin and write them on the master branch: ``` - git remote -v + git pull origin master ``` - - It will give you the name of the remote and the url, both for pull (fetch) and push. - - - To replace the current remote URL with a new one, use: + - If you made some changes on your local repository, and want to send committed changes from your local repository to the remote server (usually in the cloud, like GitHub or GitLab), you "push" these changes from your master brach to the origin by: ``` - git remote set-url origin + git push origin master ``` - - - To fetch and merge changes from the remote server into your default local branch, use: - ``` - git pull origin master + - if you want to tell Git, to make this push path (from master branch to the origin), as a default pushing path, you need to first write: ``` - - You can substitute any branch name with master, if you want to pull changes to another branch. + git push -u origin master + ``` + (which -u stands for --set-upstream). the next time you want to do the same thing, you only + need to write `git push`. - - To push changes from your local default branch to the remote repository: - ``` - git push origin master - ``` +# Adding a Remote Repository - - To track a remote branch, use: - ``` - git branch --set-upstream-to=origin/master master - ``` + - To link a remote address to your current project on your local machine, use: + ``` + git remote add origin + ``` + - For starting a project, you make an empty repository on the cloud and link it to your local repository, to save and push files also on the cloud. + - You can add multiple remotes to your projects and push them into different repositories at the same time for increased safety. + - Origin is the default remote name. You can replace the origin with any name you want in this command. - - To push the current branch and set the remote as the upstream branch, use: - ``` - git push --set-upstream origin - ``` - - **Solving Conflicts** - - So, let’s say I pulled the origin, made changes on one of the files. - And in the meanwhile, my colleague pulled and did some changes on the - same file and pushed the changes. So, it means that the current origin - state is not the same file when I fetch it. Now if I want to push, git - gives me error, saying that a conflict has happened and you cannot - make the changes you want on the origin file because it’s initial - state is changed. Usually, it guides you, telling you to pull again. - When you pull it, it tells you that you have some conflicts on the - file you have been working on. Git is rather smart, so that if you and - your colleague have changed different lines of that part, it - automatically merges the two changes and then it allows you to push. - However, if different changes have been applied to the same parts of - the code, it needs you to resolve the conflicts. So, if you use Vim - editor, you will see the changed parts highlighted in the file. Your - changes are between \<\<\<\<\<\<\< Header and =====, and his/her - changes are between \>\>\>\>\>\> (commit hash id) and =======. You can - decide which to keep and which to discard. you can also discard all - the signs (\<\<, \>\> and ===) + - To view the remotes attached to your local repository: + ``` + git remote + ``` + + - To make the output of the previous command (-v stands for "verbous"): + ``` + git remote -v + ``` + - It will give you the name of the remote and the url, both for pull (fetch) and push. + + - To replace the current remote URL with a new one, use: + ``` + git remote set-url origin + ``` + + - To fetch and merge changes from the remote server into your default local branch, use: + ``` + git pull origin master + ``` + - You can substitute any branch name with master, if you want to pull changes to another branch. + + - To push changes from your local default branch to the remote repository: + ``` + git push origin master + ``` + + - To track a remote branch, use: + ``` + git branch --set-upstream-to=origin/master master + ``` + + - To push the current branch and set the remote as the upstream branch, use: + ``` + git push --set-upstream origin + ``` + + **Solving Conflicts** + + So, let’s say I pulled the origin, made changes on one of the files. + And in the meanwhile, my colleague pulled and did some changes on the + same file and pushed the changes. So, it means that the current origin + state is not the same file when I fetch it. Now if I want to push, git + gives me error, saying that a conflict has happened and you cannot + make the changes you want on the origin file because it’s initial + state is changed. Usually, it guides you, telling you to pull again. + When you pull it, it tells you that you have some conflicts on the + file you have been working on. Git is rather smart, so that if you and + your colleague have changed different lines of that part, it + automatically merges the two changes and then it allows you to push. + However, if different changes have been applied to the same parts of + the code, it needs you to resolve the conflicts. So, if you use Vim + editor, you will see the changed parts highlighted in the file. Your + changes are between \<\<\<\<\<\<\< Header and =====, and his/her + changes are between \>\>\>\>\>\> (commit hash id) and =======. You can + decide which to keep and which to discard. you can also discard all + the signs (\<\<, \>\> and ===) # Tagging - Tags are used to mark specific points in the commit history. - **also you can make versions for your application** + Tags are used to mark specific points in the commit history. + **also you can make versions for your application** - - To show all tags: - ``` - git tag - ``` + - To show all tags: + ``` + git tag + ``` - - To create a tag for the last commit: - ``` - git tag -a -m "Your message" - ``` - - -a, is to make an annotation, which stores the message, the tagger, the commit author and the dates. - - no need to put the version in the double quotation mark. + - To create a tag for the last commit: + ``` + git tag -a -m "Your message" + ``` + - -a, is to make an annotation, which stores the message, the tagger, the commit author and the dates. + - no need to put the version in the double quotation mark. - - To create a tag for a specific commit: - ``` - git tag -a -m "Your message" - ``` - - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label it. No need to put all the hash, even a few starting characters would work. + - To create a tag for a specific commit: + ``` + git tag -a -m "Your message" + ``` + - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label it. No need to put all the hash, even a few starting characters would work. - - To show a version with all the meta related to it (the message, the tagger, the dates and the detail of the last commit before annotating that version): - ``` - git show - ``` + - To show a version with all the meta related to it (the message, the tagger, the dates and the detail of the last commit before annotating that version): + ``` + git show + ``` - - To show all the tags starting with 'v0': - ``` - git tag -l 'v0*' - ``` + - To show all the tags starting with 'v0': + ``` + git tag -l 'v0*' + ``` - - To push a specific tag to the remote: - ``` - git push origin - ``` + - To push a specific tag to the remote: + ``` + git push origin + ``` - - To push all tags to the remote: - ``` - git push origin --tags - ``` - - tags do not make any changes to the working tree, and nothing will be added on the stage (you can verify this using git status). So, if you just use ```git push origin master```, nothing will be added to the remote. + - To push all tags to the remote: + ``` + git push origin --tags + ``` + - tags do not make any changes to the working tree, and nothing will be added on the stage (you can verify this using git status). So, if you just use ```git push origin master```, nothing will be added to the remote. - - To switch to a Tag: - ``` - git checkout - ``` - - It will take you back to the last commit of this version, however, as the git also tells you, it does not create a separate branch. So, if you make a new commit, this commit will not be made on this version, but it will directly be applied to the original branch you were working on. + - To switch to a Tag: + ``` + git checkout + ``` + - It will take you back to the last commit of this version, however, as the git also tells you, it does not create a separate branch. So, if you make a new commit, this commit will not be made on this version, but it will directly be applied to the original branch you were working on. - - To verify your tag: - ``` - git tag -v - ``` + - To verify your tag: + ``` + git tag -v + ``` # GPG Keys and Signing - **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key - cryptography (asymmetric encryption)**, which uses **two mathematically - linked keys**: - - 1. **Public Key (Shared with Others)** + **Asymmetric encryption (PGP)** or **PGP (Pretty Good Privacy) encryption** is based on **public-key + cryptography (asymmetric encryption)**, which uses **two mathematically + linked keys**: + + 1. **Public Key (Shared with Others)** - - Used to **encrypt** messages. + - Used to **encrypt** messages. - - Anyone can use it to send you encrypted messages. + - Anyone can use it to send you encrypted messages. - 2. **Private Key (Kept Secret)** + 2. **Private Key (Kept Secret)** - - Used to **decrypt** messages. + - Used to **decrypt** messages. - - Only you can use it to read messages encrypted with your public - key. + - Only you can use it to read messages encrypted with your public + key. - Let’s break it down with a **real-world example**: + Let’s break it down with a **real-world example**: - **🔹 Encrypting a Message (Sending Securely)** + **🔹 Encrypting a Message (Sending Securely)** - 1. Alice wants to send a **secret** message to Bob. + 1. Alice wants to send a **secret** message to Bob. - 2. She gets **Bob’s public key** (which Bob has shared publicly). + 2. She gets **Bob’s public key** (which Bob has shared publicly). - 3. She **encrypts** the message using Bob’s **public key**. + 3. She **encrypts** the message using Bob’s **public key**. - 4. Alice sends the **encrypted message** to Bob. + 4. Alice sends the **encrypted message** to Bob. - **🔹 Decrypting a Message (Reading Securely)** + **🔹 Decrypting a Message (Reading Securely)** - 1. Bob receives the **encrypted message** from Alice. + 1. Bob receives the **encrypted message** from Alice. - 2. Since the message was encrypted using his **public key**, it can - **only** be decrypted using his **private key**. + 2. Since the message was encrypted using his **public key**, it can + **only** be decrypted using his **private key**. - 3. Bob **uses his private key** to decrypt and read the message. + 3. Bob **uses his private key** to decrypt and read the message. - GP is also used for **digital signatures** to prove identity: + GP is also used for **digital signatures** to prove identity: - 1. Bob wants to send an **authentic** message to Alice. + 1. Bob wants to send an **authentic** message to Alice. - 2. Bob **signs the message with his private key**. + 2. Bob **signs the message with his private key**. - 3. Alice **verifies the signature using Bob’s public key** to confirm - it came from him. + 3. Alice **verifies the signature using Bob’s public key** to confirm + it came from him. - GPG was for commercial and private companies, so GPG has been developed, - using the same principles for open-source use. + GPG was for commercial and private companies, so GPG has been developed, + using the same principles for open-source use. - Now, you can digitally **sign** tags and commits in git using GPG, so - full proof your identity, and make every one sure that the commit or tag - is done by you! Now, How do I make a key? + Now, you can digitally **sign** tags and commits in git using GPG, so + full proof your identity, and make every one sure that the commit or tag + is done by you! Now, How do I make a key? - - To generate a new key: - ``` - gpg --gen-key - ``` - - Now that you have your key, you give your public key to anyone who wants to see your signatures and keep your private key for signing. + - To generate a new key: + ``` + gpg --gen-key + ``` + - Now that you have your key, you give your public key to anyone who wants to see your signatures and keep your private key for signing. - - To list all your **public keys** in your keyring: - ``` - gpg --list-keys - ``` - - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name—but if they don't have your private key, they can't sign them. - - - To list all your **private (secret) keys** in your keyring: - ``` - gpg --list-secret-keys --keyid-format LONG - ``` - - This is your signing key. You’ll get something like this: the highlighted part is your key. + - To list all your **public keys** in your keyring: + ``` + gpg --list-keys + ``` + - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name—but if they don't have your private key, they can't sign them. + + - To list all your **private (secret) keys** in your keyring: + ``` + gpg --list-secret-keys --keyid-format LONG + ``` + - This is your signing key. You’ll get something like this: the highlighted part is your key. - output example: The highlighted part is your private key. - - > - > sec ed25519/`51D5C682AB1A7B0C` 2025-02-13 - > \[SC\] \[expires: 2028-02-13\] - > - > CC22A2B6C514DB471260321E51D5C682AB1A7B0C - > - > uid \[ultimate\] Jalal Abbasi \ - > - > ssb cv25519/678FBAE76D47A781 2025-02-13 \[E\] \[expires: 2028-02-13\] - - - To show your private signing key: - ``` - git config --global user.signingkey - ``` - - if you have not set any yet in git, it does not show anything. + output example: The highlighted part is your private key. + + > + > sec ed25519/`51D5C682AB1A7B0C` 2025-02-13 + > \[SC\] \[expires: 2028-02-13\] + > + > CC22A2B6C514DB471260321E51D5C682AB1A7B0C + > + > uid \[ultimate\] Jalal Abbasi \ + > + > ssb cv25519/678FBAE76D47A781 2025-02-13 \[E\] \[expires: 2028-02-13\] + + - To show your private signing key: + ``` + git config --global user.signingkey + ``` + - if you have not set any yet in git, it does not show anything. - - Set your signing key for the current user across all repositories: - ``` - git config --global user.signingKey 'your-secret-key' - ``` + - Set your signing key for the current user across all repositories: + ``` + git config --global user.signingKey 'your-secret-key' + ``` - - To tag the last commit with your signature: - ``` - git tag -s -m “message” - ``` - - - To commit with your signature: - ``` - git commit -S -m “message” - ``` - - if you use git log, it does not show if it is signed or not. + - To tag the last commit with your signature: + ``` + git tag -s -m “message” + ``` + + - To commit with your signature: + ``` + git commit -S -m “message” + ``` + - if you use git log, it does not show if it is signed or not. - - To verify if the is signed: - ``` - git tag -v - ``` - - -v here means to verify (do not mistake it with "verbous") - - if verified, you’ll get a message like: Good signature from "Jalal Abbasi " [ultimate] + - To verify if the is signed: + ``` + git tag -v + ``` + - -v here means to verify (do not mistake it with "verbous") + - if verified, you’ll get a message like: Good signature from "Jalal Abbasi " [ultimate] - - To see the excact signature characters as a part of tag message: - ``` - git show - ``` - - It is a code between two lines, as below: - >-----BEGIN PGP SIGNATURE----- - > - >iHUEABYKAB0WIQTMIqK2xRTbRxJgMh5R1caCqxp7DAUCZ65O2wAKCRBR1caCqxp7 - > - >DCIOAQCgjUvfc/cyJc7dlZxhtlJwSBj270Cu+1HXPIIhaLSpYQD+J9FXuqfwUUqK - > - >nWWqA7pTgfPWzNeJNPqujussqPns1gA= - > - >=/A/w - > - >-----END PGP SIGNATURE----- + - To see the excact signature characters as a part of tag message: + ``` + git show + ``` + - It is a code between two lines, as below: + >-----BEGIN PGP SIGNATURE----- + > + >iHUEABYKAB0WIQTMIqK2xRTbRxJgMh5R1caCqxp7DAUCZ65O2wAKCRBR1caCqxp7 + > + >DCIOAQCgjUvfc/cyJc7dlZxhtlJwSBj270Cu+1HXPIIhaLSpYQD+J9FXuqfwUUqK + > + >nWWqA7pTgfPWzNeJNPqujussqPns1gA= + > + >=/A/w + > + >-----END PGP SIGNATURE----- # Debugging Using Git - - To show all the change history about your file: - ``` - git blame - ``` - - It shows who have written which part of this last code and when. - - To show all the change history about your requested line in the requested file: - ``` - git blame -Ln - ``` - - It shows, who has written the code in line “n”, in the , in a chronological order, from the latest to the oldest. - - To show the last person who has modified the code between lines n and m and the date he/she modified them: - ``` - git blame -Ln,m - ``` - - Git Blame is useful for tracing the changes made to a file. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. - - **Bisect** + - To show all the change history about your file: + ``` + git blame + ``` + - It shows who have written which part of this last code and when. + - To show all the change history about your requested line in the requested file: + ``` + git blame -Ln + ``` + - It shows, who has written the code in line “n”, in the , in a chronological order, from the latest to the oldest. + - To show the last person who has modified the code between lines n and m and the date he/she modified them: + ``` + git blame -Ln,m + ``` + - Git Blame is useful for tracing the changes made to a file. It helps in understanding who made the changes and when they were made, which can be valuable for tracking alterations, identifying contributors, and understanding the evolution of the codebase. - (binary-search-commits): so, you are in the latest commit, and you have - a bug in your code and you want to find it, git helps you to find it in - an iterative way. + **Bisect** - So first you must go the highest level of the directory. Then you tell - git to start the process. Then you tell the latest commit is bad. Then - ask you to determine what was the latest commit in the history, that was - working fine. Given these two commits, the git goes and find the commit - between these two, and asks you to check if it is good or bad. If it is - good, it means that the bug is present between this middle commit and - the latest one, and if not, it means that the bug is present between - this middle commit and that last good commit. + (binary-search-commits): so, you are in the latest commit, and you have + a bug in your code and you want to find it, git helps you to find it in + an iterative way. - 1. ```git bisect start```: telling git to start the bisect. + So first you must go the highest level of the directory. Then you tell + git to start the process. Then you tell the latest commit is bad. Then + ask you to determine what was the latest commit in the history, that was + working fine. Given these two commits, the git goes and find the commit + between these two, and asks you to check if it is good or bad. If it is + good, it means that the bug is present between this middle commit and + the latest one, and if not, it means that the bug is present between + this middle commit and that last good commit. - 2. ```git bisect bad```: telling the git that the commit that we are now at - it, so the latest one, is bad (buggy). + 1. ```git bisect start```: telling git to start the bisect. - 3. ```git bisect good ```: then we have to tell the git the - last commit in the log, in which the code was working well. + 2. ```git bisect bad```: telling the git that the commit that we are now at + it, so the latest one, is bad (buggy). - 4. ITERATIVE: then git gives you a commit hash and asks you to check if - it is good or bad. If good, you write git bisect good, else you - write git bisect bad. Then, git now checks again, between the commit - it mentioned you, and the last or the last good commit, according to - your answer, and gives you another commit to check. Then this - iteration goes on this way. + 3. ```git bisect good ```: then we have to tell the git the + last commit in the log, in which the code was working well. + + 4. ITERATIVE: then git gives you a commit hash and asks you to check if + it is good or bad. If good, you write git bisect good, else you + write git bisect bad. Then, git now checks again, between the commit + it mentioned you, and the last or the last good commit, according to + your answer, and gives you another commit to check. Then this + iteration goes on this way. # Forking and Pull (Merge) Request - let’s say someone has a repository in their Github or Gitlab profile. - Forking means making a copy of their project and placing it on your - repository tab, so that you can work on it separately. So, you clone - this forked project and work on it on your local machine and make some - changes to it. Then, you push these changes to your own forked project. - If you want to notify the guy who originally made the project about your - changes and ask him if he wants to merge these changes also to his own - project, you send him a pull request (in Github) or merge request (in - Gitlab). the Guy will check your changes and decides whether to accept - this merge or not.** + let’s say someone has a repository in their Github or Gitlab profile. + Forking means making a copy of their project and placing it on your + repository tab, so that you can work on it separately. So, you clone + this forked project and work on it on your local machine and make some + changes to it. Then, you push these changes to your own forked project. + If you want to notify the guy who originally made the project about your + changes and ask him if he wants to merge these changes also to his own + project, you send him a pull request (in Github) or merge request (in + Gitlab). the Guy will check your changes and decides whether to accept + this merge or not.** # Other Git Commands - - Differences in using "--": + - Differences in using "--": - 1. ```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files + 1. ```--```: name is a parameter of the command: like ```git diff --staged``` 🡪 checks the staged files - 2. ```-- ```: name is a file name: like ```git checkout -- page1.html``` + 2. ```-- ```: name is a file name: like ```git checkout -- page1.html``` - - To configure git settings on three levels: - ``` - git config --system/--global/--local - ``` + - To configure git settings on three levels: + ``` + git config --system/--global/--local + ``` - | **Level** | **Scope** | **Location** | - |----|----|----| - | **System** | Applies to all users on the system | /etc/gitconfig | - | **Global** | Applies to your user across all repos | ~/.gitconfig or ~/.config/git/config | - | **Local** | Applies only to the specific repository | .git/config inside the repo | + | **Level** | **Scope** | **Location** | + |----|----|----| + | **System** | Applies to all users on the system | /etc/gitconfig | + | **Global** | Applies to your user across all repos | ~/.gitconfig or ~/.config/git/config | + | **Local** | Applies only to the specific repository | .git/config inside the repo | - - To ask for your system user: - ``` - git config --global user.name - ``` - - - To you git help: + - To ask for your system user: ``` - git help + git config --global user.name ``` + + - To you git help: + ``` + git help + ``` # Unix-Specific Commands - - ```touch ``` : To create an empty file (any type: text, html, etc) on the Git bash. - - - ```diff```: Shows the differences made in the current file - - - ```cat filename.txt```: Shows the content of the file (cat stands for concatenate) - - - ```cat file1.txt file2.txt > combined.txt```: This will **combine** file1.txt and file2.txt into a new file called combined.txt. - - - ```cat > newfile.txt```: This allows you to **create and write** to a new - file. After running the command, you can type your content, and press - Ctrl+D to save and exit. - - - ```~```: Refers to your home directory in Git Bash (C:\Users\YourUsername) - - - ```vi ```: To edit a file in Vim text editor, or create a new one is does not - exist: - - **Vim text editor**: - It is a widely used **text editor** available in almost all **Unix-based environments**, including **Linux, macOS, and BSD**. - - Here’s a compact table of basic Vi (Vim) commands: - - | **Mode** | **Command** | **Action** | - |-----------------|-------------|-----------------------------| - | **Insert Mode** | i | Insert at cursor | - | | a | Append after cursor | - | | o | Open a new line below | - | **Exit & Save** | Esc → :wq | Save and exit | - | | Esc → :x | Save and exit (same as :wq) | - | | Esc → :q! | Quit without saving | - | | Esc → :w | Save without quitting | - | **Navigation** | h | Move left | - | | l | Move right | - | | j | Move down | - | | k | Move up | - | | gg | Go to first line | - | | G | Go to last line | - | **Editing** | dd | Delete current line | - | | yy | Copy (yank) current line | - | | p | Paste after cursor | - | **Search** | /text | Search for "text" | - | | n | Jump to next match | - | | N | Jump to previous match | - | **Undo/Redo** | u | Undo last change | - | | Ctrl + r | Redo last undo | + - ```touch ``` : To create an empty file (any type: text, html, etc) on the Git bash. + + - ```diff```: Shows the differences made in the current file + + - ```cat filename.txt```: Shows the content of the file (cat stands for concatenate) + + - ```cat file1.txt file2.txt > combined.txt```: This will **combine** file1.txt and file2.txt into a new file called combined.txt. + + - ```cat > newfile.txt```: This allows you to **create and write** to a new + file. After running the command, you can type your content, and press + Ctrl+D to save and exit. + + - ```~```: Refers to your home directory in Git Bash (C:\Users\YourUsername) + + - ```vi ```: To edit a file in Vim text editor, or create a new one is does not + exist: + + **Vim text editor**: + It is a widely used **text editor** available in almost all **Unix-based environments**, including **Linux, macOS, and BSD**. + + Here’s a compact table of basic Vi (Vim) commands: + + | **Mode** | **Command** | **Action** | + |-----------------|-------------|-----------------------------| + | **Insert Mode** | i | Insert at cursor | + | | a | Append after cursor | + | | o | Open a new line below | + | **Exit & Save** | Esc → :wq | Save and exit | + | | Esc → :x | Save and exit (same as :wq) | + | | Esc → :q! | Quit without saving | + | | Esc → :w | Save without quitting | + | **Navigation** | h | Move left | + | | l | Move right | + | | j | Move down | + | | k | Move up | + | | gg | Go to first line | + | | G | Go to last line | + | **Editing** | dd | Delete current line | + | | yy | Copy (yank) current line | + | | p | Paste after cursor | + | **Search** | /text | Search for "text" | + | | n | Jump to next match | + | | N | Jump to previous match | + | **Undo/Redo** | u | Undo last change | + | | Ctrl + r | Redo last undo | From 4d0b779bbb7458f8f5f566232d4a23af5bccd647 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:30:42 +0100 Subject: [PATCH 53/75] fixing bugs --- all-notes-from-tutorial.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 7a17d285..12e46b47 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -88,10 +88,10 @@ Github Onramp course by jadi: Summary of the notes and commands ``` # Removing a file from the local repository - To remove a file from Git and your project, use: - ``` - git rm 'file-name' - ``` + To remove a file from Git and your project, use: + ``` + git rm 'file-name' + ``` # Committing Changes From 51bc1cdcb8f6b11368ea69ea199c0861d5123af3 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:30:42 +0100 Subject: [PATCH 54/75] fixing bugs --- all-notes-from-tutorial.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 7a17d285..12e46b47 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -88,10 +88,10 @@ Github Onramp course by jadi: Summary of the notes and commands ``` # Removing a file from the local repository - To remove a file from Git and your project, use: - ``` - git rm 'file-name' - ``` + To remove a file from Git and your project, use: + ``` + git rm 'file-name' + ``` # Committing Changes From b6bbbeed67834b5c57cfbd24df74dbb2de97e8f0 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:33:35 +0100 Subject: [PATCH 55/75] fixing bugs --- all-notes-from-tutorial.md | 1 + 1 file changed, 1 insertion(+) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 12e46b47..83e1b24d 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -89,6 +89,7 @@ Github Onramp course by jadi: Summary of the notes and commands # Removing a file from the local repository To remove a file from Git and your project, use: + ``` git rm 'file-name' ``` From 3e2a43d878e88ce995c1f5f428fe62590de01f8c Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:34:51 +0100 Subject: [PATCH 56/75] fixing bugs --- all-notes-from-tutorial.md | 1 - 1 file changed, 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 83e1b24d..12e46b47 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -89,7 +89,6 @@ Github Onramp course by jadi: Summary of the notes and commands # Removing a file from the local repository To remove a file from Git and your project, use: - ``` git rm 'file-name' ``` From 82adfd68c1a8ff742949f9118251b11f843d593a Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:35:38 +0100 Subject: [PATCH 57/75] fixing bugs --- all-notes-from-tutorial.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 12e46b47..97c4e29c 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -89,9 +89,10 @@ Github Onramp course by jadi: Summary of the notes and commands # Removing a file from the local repository To remove a file from Git and your project, use: - ``` - git rm 'file-name' - ``` + + ``` + git rm 'file-name' + ``` # Committing Changes From a966332339acf84137116d5141574ae092bf4461 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:37:06 +0100 Subject: [PATCH 58/75] bug fixing --- all-notes-from-tutorial.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 97c4e29c..862b1090 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -89,10 +89,10 @@ Github Onramp course by jadi: Summary of the notes and commands # Removing a file from the local repository To remove a file from Git and your project, use: - - ``` - git rm 'file-name' - ``` + + ``` + git rm 'file-name' + ``` # Committing Changes From c9b7414a58e453636c8664e742717e85ef78e6fc Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:38:38 +0100 Subject: [PATCH 59/75] bug fixing --- all-notes-from-tutorial.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 862b1090..ecd56552 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -89,7 +89,7 @@ Github Onramp course by jadi: Summary of the notes and commands # Removing a file from the local repository To remove a file from Git and your project, use: - + ``` git rm 'file-name' ``` @@ -107,13 +107,13 @@ Github Onramp course by jadi: Summary of the notes and commands Git provides several ways to view differences: - - See the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. + - To see the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. ``` git diff HEAD ``` - HEAD: is a special pointer that refers to the current branch's latest commit. However, the location of this pointer can be changed to any commit you want. - - See the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. + - To see the differences between staged changes vs. latest commit (HEAD) \> Shows **staged** modifications. ``` git diff --staged ``` From 949ff8950672d9ea9a1d54b15a9afaa439b8d23c Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:40:46 +0100 Subject: [PATCH 60/75] bug fixing --- all-notes-from-tutorial.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index ecd56552..8a1b5197 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -369,24 +369,24 @@ Github Onramp course by jadi: Summary of the notes and commands **Solving Conflicts** - So, let’s say I pulled the origin, made changes on one of the files. - And in the meanwhile, my colleague pulled and did some changes on the - same file and pushed the changes. So, it means that the current origin - state is not the same file when I fetch it. Now if I want to push, git - gives me error, saying that a conflict has happened and you cannot - make the changes you want on the origin file because it’s initial - state is changed. Usually, it guides you, telling you to pull again. - When you pull it, it tells you that you have some conflicts on the - file you have been working on. Git is rather smart, so that if you and - your colleague have changed different lines of that part, it - automatically merges the two changes and then it allows you to push. - However, if different changes have been applied to the same parts of - the code, it needs you to resolve the conflicts. So, if you use Vim - editor, you will see the changed parts highlighted in the file. Your - changes are between \<\<\<\<\<\<\< Header and =====, and his/her - changes are between \>\>\>\>\>\> (commit hash id) and =======. You can - decide which to keep and which to discard. you can also discard all - the signs (\<\<, \>\> and ===) + So, let’s say I pulled the origin, made changes on one of the files. + And in the meanwhile, my colleague pulled and did some changes on the + same file and pushed the changes. So, it means that the current origin + state is not the same file when I fetch it. Now if I want to push, git + gives me error, saying that a conflict has happened and you cannot + make the changes you want on the origin file because it’s initial + state is changed. Usually, it guides you, telling you to pull again. + When you pull it, it tells you that you have some conflicts on the + file you have been working on. Git is rather smart, so that if you and + your colleague have changed different lines of that part, it + automatically merges the two changes and then it allows you to push. + However, if different changes have been applied to the same parts of + the code, it needs you to resolve the conflicts. So, if you use Vim + editor, you will see the changed parts highlighted in the file. Your + changes are between \<\<\<\<\<\<\< Header and =====, and his/her + changes are between \>\>\>\>\>\> (commit hash id) and =======. You can + decide which to keep and which to discard. you can also discard all + the signs (\<\<, \>\> and ===) # Tagging From e891c046245a0d404daa0b543b3f4fc0c42eb5ee Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:42:28 +0100 Subject: [PATCH 61/75] Final bug fixing --- all-notes-from-tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-notes-from-tutorial.md b/all-notes-from-tutorial.md index 8a1b5197..208ea535 100644 --- a/all-notes-from-tutorial.md +++ b/all-notes-from-tutorial.md @@ -392,7 +392,7 @@ Github Onramp course by jadi: Summary of the notes and commands # Tagging Tags are used to mark specific points in the commit history. - **also you can make versions for your application** + **Also you can make versions for your application** - To show all tags: ``` From 25cc0db06f837b8d994b86bf27c8ef42c828f92a Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:51:34 +0100 Subject: [PATCH 62/75] Renamed the editted file for better content representation --- all-notes-from-tutorial.md => tutorial-notes-en.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename all-notes-from-tutorial.md => tutorial-notes-en.md (100%) diff --git a/all-notes-from-tutorial.md b/tutorial-notes-en.md similarity index 100% rename from all-notes-from-tutorial.md rename to tutorial-notes-en.md From 77f10997e6c60906dadffdcbbcb6a2b61f8cc2f9 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:56:30 +0100 Subject: [PATCH 63/75] changing again the name for capitalization --- tutorial-notes-en.md => Complete_Git_Notes-en.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tutorial-notes-en.md => Complete_Git_Notes-en.md (100%) diff --git a/tutorial-notes-en.md b/Complete_Git_Notes-en.md similarity index 100% rename from tutorial-notes-en.md rename to Complete_Git_Notes-en.md From 6434d5856e911d2ec0dfdb118ff2e97e6b711e15 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:08:49 +0100 Subject: [PATCH 64/75] Making a new folder and categorizing notes based on the language. --- .../en/Introductory_Git_Notes-en.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Introductory_Git_notes.md => Notes/en/Introductory_Git_Notes-en.md (100%) diff --git a/Introductory_Git_notes.md b/Notes/en/Introductory_Git_Notes-en.md similarity index 100% rename from Introductory_Git_notes.md rename to Notes/en/Introductory_Git_Notes-en.md From 48b50e61966ce3e31ee630465fc7e2ad395c4ffa Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:22:27 +0100 Subject: [PATCH 65/75] Moving the new adjusted file to en folder of the Notes. --- Complete_Git_Notes-en.md => Notes/en/Complete_Git_Notes-en.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Complete_Git_Notes-en.md => Notes/en/Complete_Git_Notes-en.md (100%) diff --git a/Complete_Git_Notes-en.md b/Notes/en/Complete_Git_Notes-en.md similarity index 100% rename from Complete_Git_Notes-en.md rename to Notes/en/Complete_Git_Notes-en.md From 2918adb22ceb93be9ffe2df529a6e8e5c34e701d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:28:12 +0100 Subject: [PATCH 66/75] moving also the relative png files --- git_branch.png => Notes/en/git_branch.png | Bin gpg_key_sample.png => Notes/en/gpg_key_sample.png | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename git_branch.png => Notes/en/git_branch.png (100%) rename gpg_key_sample.png => Notes/en/gpg_key_sample.png (100%) diff --git a/git_branch.png b/Notes/en/git_branch.png similarity index 100% rename from git_branch.png rename to Notes/en/git_branch.png diff --git a/gpg_key_sample.png b/Notes/en/gpg_key_sample.png similarity index 100% rename from gpg_key_sample.png rename to Notes/en/gpg_key_sample.png From bab41baa00daa04e86389aead770829c149a9e38 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:37:26 +0100 Subject: [PATCH 67/75] adding the first note file to the farsi folder --- .../fa/Jadi's-git-tutorial-contents.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jadi's-git-tutorial-contents.md => Notes/fa/Jadi's-git-tutorial-contents.md (100%) diff --git a/Jadi's-git-tutorial-contents.md b/Notes/fa/Jadi's-git-tutorial-contents.md similarity index 100% rename from Jadi's-git-tutorial-contents.md rename to Notes/fa/Jadi's-git-tutorial-contents.md From 31fa444b47ba698b905d827ad6b67bc52f5f4711 Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:39:33 +0100 Subject: [PATCH 68/75] adding the second finglish! file to the notes folder --- .../fa/all-of-commands-git-jadi.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename all-of-commands-git-jadi.txt => Notes/fa/all-of-commands-git-jadi.txt (100%) diff --git a/all-of-commands-git-jadi.txt b/Notes/fa/all-of-commands-git-jadi.txt similarity index 100% rename from all-of-commands-git-jadi.txt rename to Notes/fa/all-of-commands-git-jadi.txt From fbb5c801471a5a586bd16768e424e934414a6c1d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:41:47 +0100 Subject: [PATCH 69/75] adding the html file to the en folder of the notes --- git_commands.html => Notes/en/git_commands.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename git_commands.html => Notes/en/git_commands.html (100%) diff --git a/git_commands.html b/Notes/en/git_commands.html similarity index 100% rename from git_commands.html rename to Notes/en/git_commands.html From 0d6ffefb402539ed3244c4b2c146b21aed03de8d Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:53:37 +0100 Subject: [PATCH 70/75] Adding a note for the course material --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5141dbab..7d5a8727 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # **Hello** -> Note: Its better to add your name somewhere in the middle, and not at the beginning nor at the end! +> Note #1: Its better to add your name somewhere in the middle, and not at the beginning nor at the end! +> Note #2: The course material, including notes and command summaries are already present in both English and Farsi in the "Notes" folder. You can download and keep them as a general reference. Also, feel free to add/edit their contents if needed. -> نکته: بهتره اسمتون رو یه جایی وسط لیست اضافه کنین و نه دقیقا اول یا آخر لیست +> نکته ۱: بهتره اسمتون رو یه جایی وسط لیست اضافه کنین و نه دقیقا اول یا آخر لیست +> نکته ۲: جزوه ی این کورس، هم به زبان انگلیسی و هم به زبان فارسی در پوشه ی نوت ها موجود هست. میتونید اونا رو دانلود کنید و به عنوان یه مرجع کلی برای خودتون نگه دارید. همچنین، در صورت نیاز میتونید اون ها رو اصلاح کنید یا اطلاعات جدیدی بهشون اضافه کنید. This is a repo for testing your git abilities. try to add your name to this file @@ -102,6 +104,7 @@ feel free to use these emojis: https://gist.github.com/rxaviers/7360908 :relaxed - [Saeed Barari](https://github.com/Saeedb021) - [Mohammadhossein Asadi 🎯](https://github.com/mohammadhossein-asadi) - [Mousa Pashaee](https://github.com/mousa-1983) +- [jalal-abbasi](https://github.com/jalal-abbasi) - [mohammad mojaver](https://github.com/mohammadDeveloperr) - [Mahdi Peydai](https://github.com/MahdiPeydai) - [Radman](https://github.com/radman17)👽 From 9e830a16660c339ff9b2aed34cb7b8a7ccaa060e Mon Sep 17 00:00:00 2001 From: jalal-abbasi <72163298+jalal-abbasi@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:54:37 +0100 Subject: [PATCH 71/75] fixing the spacing problem --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7d5a8727..8a393b4d 100755 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # **Hello** > Note #1: Its better to add your name somewhere in the middle, and not at the beginning nor at the end! + > Note #2: The course material, including notes and command summaries are already present in both English and Farsi in the "Notes" folder. You can download and keep them as a general reference. Also, feel free to add/edit their contents if needed. > نکته ۱: بهتره اسمتون رو یه جایی وسط لیست اضافه کنین و نه دقیقا اول یا آخر لیست + > نکته ۲: جزوه ی این کورس، هم به زبان انگلیسی و هم به زبان فارسی در پوشه ی نوت ها موجود هست. میتونید اونا رو دانلود کنید و به عنوان یه مرجع کلی برای خودتون نگه دارید. همچنین، در صورت نیاز میتونید اون ها رو اصلاح کنید یا اطلاعات جدیدی بهشون اضافه کنید. This is a repo for testing your git abilities. try to add your name to this file From be6841e834c8e2199b78464f6bc70e8761342125 Mon Sep 17 00:00:00 2001 From: Jalal Abbasi Date: Wed, 26 Feb 2025 12:02:26 +0100 Subject: [PATCH 72/75] Delete lots of love for jadi.py --- lots of love for jadi.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 lots of love for jadi.py diff --git a/lots of love for jadi.py b/lots of love for jadi.py deleted file mode 100644 index 87044450..00000000 --- a/lots of love for jadi.py +++ /dev/null @@ -1,3 +0,0 @@ -for x in range(0,1000): - print( ' For ' , x , ' number I love you jadi ! ' ) - print( ' Like lots of peoples i learn lots of things from you :) ' ) From 694649462c42143f530f301a576055ab35769cf6 Mon Sep 17 00:00:00 2001 From: Jalal Abbasi Date: Mon, 3 Mar 2025 21:35:02 +0100 Subject: [PATCH 73/75] Update Complete_Git_Notes-en.md Adding new information on deleting a folder from local repo and git tracking. --- Notes/en/Complete_Git_Notes-en.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Notes/en/Complete_Git_Notes-en.md b/Notes/en/Complete_Git_Notes-en.md index 208ea535..b82ca81b 100644 --- a/Notes/en/Complete_Git_Notes-en.md +++ b/Notes/en/Complete_Git_Notes-en.md @@ -49,7 +49,7 @@ Github Onramp course by jadi: Summary of the notes and commands ``` - Tells you which files are modified, staged, or untracked and helps you understand what changes need to be committed. - - To show the log (history) of the all commits you have made: + - To show the log (history) of all the commits you have made: ``` git log ``` @@ -60,7 +60,7 @@ Github Onramp course by jadi: Summary of the notes and commands # Adding Files to the Staging Area - To Add files to the staging area to prepare them for commit. You have several options: + To add files to the staging area to prepare them for commit. You have several options: - To add all (the changed) files: ``` @@ -88,12 +88,22 @@ Github Onramp course by jadi: Summary of the notes and commands ``` # Removing a file from the local repository - To remove a file from Git and your project, use: - - ``` - git rm 'file-name' - ``` + - To remove a file from Git and your project, use: + ``` + git rm 'file-name' + ``` + - To remove a folder from the local repository and git: + ``` + git rm -r 'folder-name' + ``` + + - To remove a folder from only from git tracking (keeping it in the local repo): + ``` + git rm -r --cached 'folder-name' + ``` + - -r: Recursively removes directories and their contents from Git tracking. The term "recursive" means Git goes inside the folder and applies the command to all its contents, like subfolders and files. + - --cached: Removes the file(s) from the Git index (staging area) but keeps them in your local filesystem. # Committing Changes To save the staged changes as a new snapshot, use the `git commit` command: From 780f870641c025fbfa8566e5f588958a05782b81 Mon Sep 17 00:00:00 2001 From: Jalal Abbasi Date: Sun, 6 Apr 2025 20:44:20 +0200 Subject: [PATCH 74/75] Update Complete_Git_Notes-en.md Added a common command to remove files/folders from the local repo. And, also corrected grammatical and spelling errors. --- Notes/en/Complete_Git_Notes-en.md | 140 +++++++++++++++--------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/Notes/en/Complete_Git_Notes-en.md b/Notes/en/Complete_Git_Notes-en.md index b82ca81b..861eba61 100644 --- a/Notes/en/Complete_Git_Notes-en.md +++ b/Notes/en/Complete_Git_Notes-en.md @@ -1,4 +1,4 @@ -Github Onramp course by jadi: Summary of the notes and commands +Github Onramp course by Jadi: Summary of the notes and commands # Table of Contents - [Initializing a Git Project](#Initializing-a-Git-Project) @@ -104,6 +104,7 @@ Github Onramp course by jadi: Summary of the notes and commands ``` - -r: Recursively removes directories and their contents from Git tracking. The term "recursive" means Git goes inside the folder and applies the command to all its contents, like subfolders and files. - --cached: Removes the file(s) from the Git index (staging area) but keeps them in your local filesystem. + # Committing Changes To save the staged changes as a new snapshot, use the `git commit` command: @@ -117,7 +118,7 @@ Github Onramp course by jadi: Summary of the notes and commands Git provides several ways to view differences: - - To see the differences between the unstaged changes vs. latest commit (HEAD) \> Shows **unstaged** modifications. + - To see the differences between the unstaged changes vs. the latest commit (HEAD) \> Shows **unstaged** modifications. ``` git diff HEAD ``` @@ -130,8 +131,7 @@ Github Onramp course by jadi: Summary of the notes and commands Example: - I make one change in the pag1.html, then add it to the stage then make - another change, without adding: + I make one change in the pag1.html, then add it to the stage, then make another change, without adding: @@ -175,7 +175,7 @@ Github Onramp course by jadi: Summary of the notes and commands
-# Reseting and Exiting the Staging Area +# Resetting and Exiting the Staging Area To manipulate the state of your working directory, staging area, and commit history, you can use the `git reset` command: @@ -206,8 +206,12 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git restore --staged * ``` + - To remove a file/folder from Git local repository (and not from your working directory), so that it is no longer trackable by Git: + ''' + git rm --cashed -r + ''' - - To restore file content back to latest commit: + - To restore file content back to the latest commit: ``` git restore ``` @@ -227,19 +231,19 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git checkout -- ``` - - if you have not yet committed the changes, it will undo all changes and brings the file back to the previous commit file status. So, it restores all the changes back to the latest commit. + - If you have not yet committed the changes, it will undo all changes and brings the file back to the previous commit file status. So, it restores all the changes back to the latest commit. - `'--'`: Refers to the HEAD (latest commit). # Working With Branches - When you create a new branch, it **inherits the current state** of your working directory and index.Managing branches is essential for collaboration and project organization. Here are some branch-related commands: + When you create a new branch, it **inherits the current state** of your working directory and index. Managing branches is essential for collaboration and project organization. Here are some branch-related commands: - To show all branches in the project: ``` git branch ``` - - The output highlights your current working branch with an astrix (\*). + - The output highlights your current working branch with an asterisk (\*). Example: > \$ git branch > @@ -247,7 +251,7 @@ Github Onramp course by jadi: Summary of the notes and commands > > \* master - - To Create a new branch for your project: + - To create a new branch for your project: ``` git branch 'branch-name' ``` @@ -262,13 +266,13 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git checkout 'branch-name' ``` - - so, let’s say you make a new branch and go to this branch, make some files and change the contents of the other. If you switch back the master using checkout, all the files and changes that you have made will disappear from your computer directory! + - So, let’s say you make a new branch and go to this branch, make some files, and change the contents of the other. If you switch back to the master using checkout, all the files and changes that you have made will disappear from your computer directory! - To merge a branch into your current branch, use: ``` git merge 'branch-name' ``` - - it merges the changes you made in the new branch on the branch master. note that before using this command you have to checkout first to the branch master. + - It merges the changes you made in the new branch into the master branch. Note that before using this command, you have to check out first to the master branch. - When you switch from one branch to the other (let’s say from master to a new branch named "linkingpages") the git bash interface will show a message, telling you what is different in your working directory compared to linkingpages after switching. D means deleted, and M means modified. In this example, one file has been modified and one has been deleted, comparing the branch content with the working directory: @@ -282,12 +286,12 @@ Github Onramp course by jadi: Summary of the notes and commands > > Switched to branch 'linkingpages' - When you make changes in your working directory without staging them and then switch branches, Git will try to preserve your changes, but the behavior depends on whether those changes conflict with the files in the branch you're switching to. - - until you merge the branch with the master, you cannot see the changes you made on that branch also in the master. + - Until you merge the branch with the master, you cannot see the changes you made on that branch or in the master. # Cloning a Remote Repository - Remote is a reference to a repository on a server, like github or - gitlab, or even another machine. If you clone a repository from + Remote refers to a repository on a server, like GitHub or + GitLab, or even another machine. If you clone a repository from GitHub, Git automatically creates a remote reference called origin. Origin is the default name given to a remote repository when you @@ -308,26 +312,26 @@ Github Onramp course by jadi: Summary of the notes and commands > fetch = +refs/heads/\*:refs/remotes/origin/\* > This configuration section is where **origin** is the reference, and - the **URL** (https://github.com/user/repo.git) is the data that Git + The **URL** (https://github.com/user/repo.git) is the data that Git uses to access the remote repository. - - Clonning a project means making a copy of a remote project from a remote location (like GitHub) on your local directory. To do so we use this command: + - Cloning a project means making a copy of a remote project from a remote location (like GitHub) to your local directory. To do so, we use this command: ``` git clone ``` - - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This in Git terminology is called "pulling". We pull the file from the origin and write them on the master branch: + - When you already have the repository cloned and want to update it, you want to fetch and merge the latest changes from a remote branch into your current local branch. This, in Git terminology, is called "pulling". We pull the file from the origin and write it on the master branch: ``` git pull origin master ``` - - If you made some changes on your local repository, and want to send committed changes from your local repository to the remote server (usually in the cloud, like GitHub or GitLab), you "push" these changes from your master brach to the origin by: + - If you made some changes on your local repository, and want to send committed changes from your local repository to the remote server (usually in the cloud, like GitHub or GitLab), you "push" these changes from your master branch to the origin by: ``` git push origin master ``` - - if you want to tell Git, to make this push path (from master branch to the origin), as a default pushing path, you need to first write: + - If you want to tell Git to make this push path (from master branch to the origin), as a default pushing path, you need to first write: ``` git push -u origin master ``` - (which -u stands for --set-upstream). the next time you want to do the same thing, you only + (which -u stands for --set-upstream). The next time you want to do the same thing, you only need to write `git push`. # Adding a Remote Repository @@ -345,7 +349,7 @@ Github Onramp course by jadi: Summary of the notes and commands git remote ``` - - To make the output of the previous command (-v stands for "verbous"): + - To make the output of the previous command (-v stands for "verbose"): ``` git remote -v ``` @@ -360,7 +364,7 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git pull origin master ``` - - You can substitute any branch name with master, if you want to pull changes to another branch. + - You can substitute any branch name with master if you want to pull changes to another branch. - To push changes from your local default branch to the remote repository: ``` @@ -380,18 +384,18 @@ Github Onramp course by jadi: Summary of the notes and commands **Solving Conflicts** So, let’s say I pulled the origin, made changes on one of the files. - And in the meanwhile, my colleague pulled and did some changes on the + And in the meantime, my colleague pulled and made some changes to the same file and pushed the changes. So, it means that the current origin - state is not the same file when I fetch it. Now if I want to push, git - gives me error, saying that a conflict has happened and you cannot - make the changes you want on the origin file because it’s initial + state is not the same file when I fetch it. Now, if I want to push, git + gives mean error, saying that a conflict has happened and you cannot + make the changes you want on the origin file because its initial state is changed. Usually, it guides you, telling you to pull again. - When you pull it, it tells you that you have some conflicts on the - file you have been working on. Git is rather smart, so that if you and + When you pull it, it tells you that you have some conflicts in the + file you have been working on. Git is rather smart, so if you and your colleague have changed different lines of that part, it - automatically merges the two changes and then it allows you to push. + automatically merges the two changes, and then it allows you to push. However, if different changes have been applied to the same parts of - the code, it needs you to resolve the conflicts. So, if you use Vim + the code, it needs you to resolve the conflicts. So, if you use the Vim editor, you will see the changed parts highlighted in the file. Your changes are between \<\<\<\<\<\<\< Header and =====, and his/her changes are between \>\>\>\>\>\> (commit hash id) and =======. You can @@ -402,7 +406,7 @@ Github Onramp course by jadi: Summary of the notes and commands # Tagging Tags are used to mark specific points in the commit history. - **Also you can make versions for your application** + **Also, you can make versions for your application** - To show all tags: ``` @@ -413,16 +417,16 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git tag -a -m "Your message" ``` - - -a, is to make an annotation, which stores the message, the tagger, the commit author and the dates. - - no need to put the version in the double quotation mark. + - -a is to make an annotation, which stores the message, the tagger, the commit author and the dates. + - No need to put the version in the double quotation mark. - To create a tag for a specific commit: ``` git tag -a -m "Your message" ``` - - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label it. No need to put all the hash, even a few starting characters would work. + - You can use git log to see the history of all commits and then copy the hash of the commit action you want to label. No need to put all the hash, even a few starting characters would work. - - To show a version with all the meta related to it (the message, the tagger, the dates and the detail of the last commit before annotating that version): + - To show a version with all the meta related to it (the message, the tagger, the dates, and the detail of the last commit before annotating that version): ``` git show ``` @@ -441,13 +445,13 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git push origin --tags ``` - - tags do not make any changes to the working tree, and nothing will be added on the stage (you can verify this using git status). So, if you just use ```git push origin master```, nothing will be added to the remote. + - Tags do not make any changes to the working tree, and nothing will be added to the stage (you can verify this using git status). So, if you just use ```git push origin master```, nothing will be added to the remote. - To switch to a Tag: ``` git checkout ``` - - It will take you back to the last commit of this version, however, as the git also tells you, it does not create a separate branch. So, if you make a new commit, this commit will not be made on this version, but it will directly be applied to the original branch you were working on. + - It will take you back to the last commit of this version; however, as git also tells you, it does not create a separate branch. So, if you make a new commit, this commit will not be made on this version, but it will be applied directly to the original branch you were working on. - To verify your tag: ``` @@ -470,8 +474,8 @@ Github Onramp course by jadi: Summary of the notes and commands - Used to **decrypt** messages. - - Only you can use it to read messages encrypted with your public - key. + - Only you can use it to read messages encrypted with your public key + Let’s break it down with a **real-world example**: @@ -503,12 +507,12 @@ Github Onramp course by jadi: Summary of the notes and commands 3. Alice **verifies the signature using Bob’s public key** to confirm it came from him. - GPG was for commercial and private companies, so GPG has been developed, + GPG was for commercial and private companies, so GPG has been developed. using the same principles for open-source use. Now, you can digitally **sign** tags and commits in git using GPG, so - full proof your identity, and make every one sure that the commit or tag - is done by you! Now, How do I make a key? + fully prove your identity, and make every one sure that the commit or tag + is done by you! Now, how do I make a key? - To generate a new key: ``` @@ -520,7 +524,7 @@ Github Onramp course by jadi: Summary of the notes and commands ``` gpg --list-keys ``` - - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name—but if they don't have your private key, they can't sign them. + - Your public key allows others to verify your signature. Without your public key, people can still see your commits/tags, but they can't verify their authenticity. It ensures that no one else has forged your identity to push commits under your name. Anyone can set their Git username and email to pretend to be you: by git config --global user.name "Your Name" and git config --global user.email . This means someone can fake commits under your name, but if they don't have your private key, they can't sign them. - To list all your **private (secret) keys** in your keyring: ``` @@ -544,7 +548,7 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git config --global user.signingkey ``` - - if you have not set any yet in git, it does not show anything. + - If you have not set any yet in git, it does not show anything. - Set your signing key for the current user across all repositories: ``` @@ -560,16 +564,16 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git commit -S -m “message” ``` - - if you use git log, it does not show if it is signed or not. + - If you use git log, it does not show if it is signed or not. - To verify if the is signed: ``` git tag -v ``` - -v here means to verify (do not mistake it with "verbous") - - if verified, you’ll get a message like: Good signature from "Jalal Abbasi " [ultimate] + - If verified, you’ll get a message like: Good signature from "Jalal Abbasi " [ultimate] - - To see the excact signature characters as a part of tag message: + - To see the exact signature characters as a part of the tag message: ``` git show ``` @@ -593,13 +597,13 @@ Github Onramp course by jadi: Summary of the notes and commands ``` git blame ``` - - It shows who have written which part of this last code and when. + - It shows who has written which part of this last code and when. - To show all the change history about your requested line in the requested file: ``` git blame -Ln ``` - - It shows, who has written the code in line “n”, in the , in a chronological order, from the latest to the oldest. - - To show the last person who has modified the code between lines n and m and the date he/she modified them: + - It shows who has written the code in line “n”, in the , in a chronological order, from the latest to the oldest. + - To show the last person who has modified the code between lines n and m and the date he/she modified it: ``` git blame -Ln,m ``` @@ -607,14 +611,13 @@ Github Onramp course by jadi: Summary of the notes and commands **Bisect** - (binary-search-commits): so, you are in the latest commit, and you have - a bug in your code and you want to find it, git helps you to find it in - an iterative way. + (binary-search-commits)So, you are in the latest commit, and you have + a bug in your code, and you want to find it, git helps you to find it iteratively. - So first you must go the highest level of the directory. Then you tell - git to start the process. Then you tell the latest commit is bad. Then - ask you to determine what was the latest commit in the history, that was - working fine. Given these two commits, the git goes and find the commit + So first, you must go to the highest level of the directory. Then you tell + git to start the process. Then you say the latest commit is bad. Then + ask you to determine what was the latest commit was in the history, which was + working fine. Given these two commits, git goes and finds the commit between these two, and asks you to check if it is good or bad. If it is good, it means that the bug is present between this middle commit and the latest one, and if not, it means that the bug is present between @@ -622,13 +625,12 @@ Github Onramp course by jadi: Summary of the notes and commands 1. ```git bisect start```: telling git to start the bisect. - 2. ```git bisect bad```: telling the git that the commit that we are now at + 2. ```git bisect bad```: telling git that the commit that we are now at it, so the latest one, is bad (buggy). - 3. ```git bisect good ```: then we have to tell the git the - last commit in the log, in which the code was working well. + 3. ```git bisect good ```: Then we have to tell git the last commit in the log, in which the code was working well. - 4. ITERATIVE: then git gives you a commit hash and asks you to check if + 4. ITERATIVE: Then git gives you a commit hash and asks you to check if it is good or bad. If good, you write git bisect good, else you write git bisect bad. Then, git now checks again, between the commit it mentioned you, and the last or the last good commit, according to @@ -637,15 +639,15 @@ Github Onramp course by jadi: Summary of the notes and commands # Forking and Pull (Merge) Request - let’s say someone has a repository in their Github or Gitlab profile. + Let’s say someone has a repository in their GitHub or GitLab profile. Forking means making a copy of their project and placing it on your repository tab, so that you can work on it separately. So, you clone this forked project and work on it on your local machine and make some changes to it. Then, you push these changes to your own forked project. If you want to notify the guy who originally made the project about your changes and ask him if he wants to merge these changes also to his own - project, you send him a pull request (in Github) or merge request (in - Gitlab). the Guy will check your changes and decides whether to accept + project, you send him a pull request (in GitHub) or a merge request (in + Gitlab). The guy will check your changes and decide whether to accept this merge or not.** # Other Git Commands @@ -671,14 +673,14 @@ Github Onramp course by jadi: Summary of the notes and commands git config --global user.name ``` - - To you git help: + - To you, git help: ``` git help ``` # Unix-Specific Commands - - ```touch ``` : To create an empty file (any type: text, html, etc) on the Git bash. + - ```touch ```: To create an empty file (any type: text, html, etc) on the Git bash. - ```diff```: Shows the differences made in the current file @@ -687,12 +689,12 @@ Github Onramp course by jadi: Summary of the notes and commands - ```cat file1.txt file2.txt > combined.txt```: This will **combine** file1.txt and file2.txt into a new file called combined.txt. - ```cat > newfile.txt```: This allows you to **create and write** to a new - file. After running the command, you can type your content, and press + file. After running the command, you can type your content and press Ctrl+D to save and exit. - ```~```: Refers to your home directory in Git Bash (C:\Users\YourUsername) - - ```vi ```: To edit a file in Vim text editor, or create a new one is does not + - ```vi ```: To edit a file in Vim text editor, or create a new one, does not exist: **Vim text editor**: From bf20e5742f9e5f79442838cd767a3ad1c5d04a72 Mon Sep 17 00:00:00 2001 From: Jalal Abbasi Date: Sun, 6 Apr 2025 20:46:44 +0200 Subject: [PATCH 75/75] Update Complete_Git_Notes-en.md deleted the previous command because it was already there, but in another section. --- Notes/en/Complete_Git_Notes-en.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Notes/en/Complete_Git_Notes-en.md b/Notes/en/Complete_Git_Notes-en.md index 861eba61..652d90c0 100644 --- a/Notes/en/Complete_Git_Notes-en.md +++ b/Notes/en/Complete_Git_Notes-en.md @@ -98,7 +98,7 @@ Github Onramp course by Jadi: Summary of the notes and commands git rm -r 'folder-name' ``` - - To remove a folder from only from git tracking (keeping it in the local repo): + - To remove a folder from only git tracking (keeping it in the local repo): ``` git rm -r --cached 'folder-name' ``` @@ -206,10 +206,6 @@ Github Onramp course by Jadi: Summary of the notes and commands ``` git restore --staged * ``` - - To remove a file/folder from Git local repository (and not from your working directory), so that it is no longer trackable by Git: - ''' - git rm --cashed -r - ''' - To restore file content back to the latest commit: ```