From 4babb4bd19ae35564074c5b9485c67f11531de34 Mon Sep 17 00:00:00 2001 From: "NEWCO\\znagar" Date: Fri, 20 May 2022 02:17:53 +0300 Subject: [PATCH 1/5] Done --- 07_git_exercises/zoharn007_ex1/README | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 07_git_exercises/zoharn007_ex1/README diff --git a/07_git_exercises/zoharn007_ex1/README b/07_git_exercises/zoharn007_ex1/README new file mode 100644 index 00000000..6f276a1b --- /dev/null +++ b/07_git_exercises/zoharn007_ex1/README @@ -0,0 +1,80 @@ +------------------------------------------------------------ +Git Basics (commit, diff, branches): +------------------------------------------------------------ + +1(A) touch abc.txt + echo 1 > abc.txt +2(A) The color is Red +3(A) git add abc.txt + The color is now green (after adding to index) +4(A) echo 2 >> abc.txt +5(A) The color is now Blue +6(A) git diff HEAD +7(A) There is nothing to print because the command above shows the changes between “Index” and “HEAD” and there is nothing on Index (we only + changed the working copy. +8(A) Invalid command (ambigous argument) +9(A) git add abc.txt +10(A) There is nothing to print because the command above shows the changes between “Index” and “Working copy” and right now they are identical (both contain “1” and “2”). +11(A) git diff --staged +12(A) echo 3 >> abc.txt +13(A) We have: “1” at abc.txt in main, “1”, “2” at abc.txt in index and “1”, “2” , "3" at abc.txt in working copy. + Since “main”, “index” and ”working copy” contain different values the output is different. +14(A) abc.txt appears twice because we have one copy of abc.txt in index (contain “1” and “2”) and another copy in working copy (“1”, “2” and “3”) +15(A) git restore --staged --worktree abc.txt + +------------------------------------------------------------ +Resolve conflicts: +------------------------------------------------------------ + +1(A) git branch +2(A) git checkout -b feature/lambda_migration +3(A) git merge feature/version1 +4(A) done as described on Pycharm UI +5(A) done as described on Pycharm UI +6(A) c20f43d (HEAD -> feature/lambda_migration) Merge branch 'feature/version2' into feature/lambda_migration + 18c07cb Merge branch 'feature/version1' into feature/lambda_migration + +------------------------------------------------------------ +Cherry picking: +------------------------------------------------------------ + +1(A) git checkout main + git branch feature/lambda_migration2 +2(A) done as described on Pycharm UI +3(A) done as described on Pycharm UI +4(A) .env and config.json +5(A) Yes, you should care because they can be related. For example, if the 1st commit creates “file.txt” and the 2nd commit updates “file.txt”, you can’t reverse the order of picking. + +------------------------------------------------------------ +Changes in working tree and switch branches: +------------------------------------------------------------ + +1(A) done as described +2(A) touch take.txt + echo "How are you?" >> take.txt + echo "I am fine, thank you." >> take.txt + git add take.txt +3(A) git checkout dev + + The error is: + "error: Your local changes to the following files would be overwritten by checkout: + take.txt + Please commit your changes or stash them before you switch branches. + Aborting" + + The two suggested approaches are: comit or stash before switch branches. + +4(A) done as described on Pycharm UI +5(A) No, it contains “a”, “b” and “c” +6(A) No, take.txt is missing. “Force Checkout” remove all uncommitted changes (in index and working copy). + +------------------------------------------------------------ +Reset: +------------------------------------------------------------ + +1(A) git checkout reset_question +2(A) 1. git reset --soft HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("9"). The file "10" is uncommitted and is now in index (becomes green). + 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). The file "9" is uncomitted, the file "10" unindexed, both become red (untracked files). + 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). The file "8" uncommitted and removed. + 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with this change. (HEAD is now the new commit). +3(A) HEAD~1 is the previous commit from the current HEAD. \ No newline at end of file From 9cb8f78a316a4cae17ad562c738b21ed4b4019ee Mon Sep 17 00:00:00 2001 From: "NEWCO\\znagar" Date: Fri, 20 May 2022 02:23:02 +0300 Subject: [PATCH 2/5] Done --- 07_git_exercises/zoharn007_ex1/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/07_git_exercises/zoharn007_ex1/README b/07_git_exercises/zoharn007_ex1/README index 6f276a1b..f13253e6 100644 --- a/07_git_exercises/zoharn007_ex1/README +++ b/07_git_exercises/zoharn007_ex1/README @@ -62,7 +62,7 @@ Changes in working tree and switch branches: Please commit your changes or stash them before you switch branches. Aborting" - The two suggested approaches are: comit or stash before switch branches. + The two suggested approaches are: commit or stash before switch branches. 4(A) done as described on Pycharm UI 5(A) No, it contains “a”, “b” and “c” @@ -74,7 +74,7 @@ Reset: 1(A) git checkout reset_question 2(A) 1. git reset --soft HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("9"). The file "10" is uncommitted and is now in index (becomes green). - 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). The file "9" is uncomitted, the file "10" unindexed, both become red (untracked files). + 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). The file "9" is uncommitted, the file "10" unindexed, both become red (untracked files). 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). The file "8" uncommitted and removed. 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with this change. (HEAD is now the new commit). 3(A) HEAD~1 is the previous commit from the current HEAD. \ No newline at end of file From cd0e54087e08fd9be22dac23906d5e4afb46fa37 Mon Sep 17 00:00:00 2001 From: "NEWCO\\znagar" Date: Fri, 20 May 2022 02:47:03 +0300 Subject: [PATCH 3/5] Done --- 07_git_exercises/zoharn007_ex1/README | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/07_git_exercises/zoharn007_ex1/README b/07_git_exercises/zoharn007_ex1/README index f13253e6..57ef0f9d 100644 --- a/07_git_exercises/zoharn007_ex1/README +++ b/07_git_exercises/zoharn007_ex1/README @@ -17,10 +17,9 @@ Git Basics (commit, diff, branches): 10(A) There is nothing to print because the command above shows the changes between “Index” and “Working copy” and right now they are identical (both contain “1” and “2”). 11(A) git diff --staged 12(A) echo 3 >> abc.txt -13(A) We have: “1” at abc.txt in main, “1”, “2” at abc.txt in index and “1”, “2” , "3" at abc.txt in working copy. - Since “main”, “index” and ”working copy” contain different values the output is different. -14(A) abc.txt appears twice because we have one copy of abc.txt in index (contain “1” and “2”) and another copy in working copy (“1”, “2” and “3”) -15(A) git restore --staged --worktree abc.txt +13(A) No, since “main”, “index” and ”working copy” are have different changes, the output is different. +14(A) abc.txt appears twice because we have one copy of abc.txt in index ready to commit and another modified abc.txt in working copy. +15(A) git reset --hard ------------------------------------------------------------ Resolve conflicts: @@ -73,8 +72,11 @@ Reset: ------------------------------------------------------------ 1(A) git checkout reset_question -2(A) 1. git reset --soft HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("9"). The file "10" is uncommitted and is now in index (becomes green). - 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). The file "9" is uncommitted, the file "10" unindexed, both become red (untracked files). - 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). The file "8" uncommitted and removed. +2(A) 1. git reset --soft HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("9"). + The file "10" is uncommitted and is now in index (becomes green) and ready to be committed. + 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). + The file "9" is uncommitted, the file "10" unindexed, both become red (untracked files). + 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). + The file "8" uncommitted and removed. 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with this change. (HEAD is now the new commit). 3(A) HEAD~1 is the previous commit from the current HEAD. \ No newline at end of file From 3b32d2235baffb9b04bfc32c9308132ff037a67c Mon Sep 17 00:00:00 2001 From: "NEWCO\\znagar" Date: Fri, 20 May 2022 02:54:31 +0300 Subject: [PATCH 4/5] Done --- 07_git_exercises/zoharn007_ex1/README | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/07_git_exercises/zoharn007_ex1/README b/07_git_exercises/zoharn007_ex1/README index 57ef0f9d..07cf14a3 100644 --- a/07_git_exercises/zoharn007_ex1/README +++ b/07_git_exercises/zoharn007_ex1/README @@ -10,15 +10,17 @@ Git Basics (commit, diff, branches): 4(A) echo 2 >> abc.txt 5(A) The color is now Blue 6(A) git diff HEAD -7(A) There is nothing to print because the command above shows the changes between “Index” and “HEAD” and there is nothing on Index (we only - changed the working copy. +7(A) There is nothing to print because the command above shows the changes between “Index” and “HEAD” and there is + nothing on Index (we only changed the working copy. 8(A) Invalid command (ambigous argument) 9(A) git add abc.txt -10(A) There is nothing to print because the command above shows the changes between “Index” and “Working copy” and right now they are identical (both contain “1” and “2”). +10(A) There is nothing to print because the command above shows the changes between “Index” and “Working copy” and + right now they are identical. 11(A) git diff --staged 12(A) echo 3 >> abc.txt 13(A) No, since “main”, “index” and ”working copy” are have different changes, the output is different. -14(A) abc.txt appears twice because we have one copy of abc.txt in index ready to commit and another modified abc.txt in working copy. +14(A) abc.txt appears twice because we have one copy of abc.txt in index ready to commit and another modified abc.txt + in working copy. 15(A) git reset --hard ------------------------------------------------------------ @@ -42,7 +44,8 @@ Cherry picking: 2(A) done as described on Pycharm UI 3(A) done as described on Pycharm UI 4(A) .env and config.json -5(A) Yes, you should care because they can be related. For example, if the 1st commit creates “file.txt” and the 2nd commit updates “file.txt”, you can’t reverse the order of picking. +5(A) Yes, you should care because they can be related. For example, if the 1st commit creates “file.txt” and the + 2nd commit updates “file.txt”, you can’t reverse the order of picking. ------------------------------------------------------------ Changes in working tree and switch branches: @@ -78,5 +81,6 @@ Reset: The file "9" is uncommitted, the file "10" unindexed, both become red (untracked files). 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). The file "8" uncommitted and removed. - 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with this change. (HEAD is now the new commit). -3(A) HEAD~1 is the previous commit from the current HEAD. \ No newline at end of file + 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with + this change. (HEAD is now the new commit). +3(A) HEAD~1 is the previous commit from the current HEAD. From 05979db24c28d87ac77ec3604c7c259c94a91ae0 Mon Sep 17 00:00:00 2001 From: "NEWCO\\znagar" Date: Fri, 20 May 2022 03:58:30 +0300 Subject: [PATCH 5/5] Done --- 07_git_exercises/zoharn007_ex1/README | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/07_git_exercises/zoharn007_ex1/README b/07_git_exercises/zoharn007_ex1/README index 07cf14a3..1ee4f6be 100644 --- a/07_git_exercises/zoharn007_ex1/README +++ b/07_git_exercises/zoharn007_ex1/README @@ -64,7 +64,8 @@ Changes in working tree and switch branches: Please commit your changes or stash them before you switch branches. Aborting" - The two suggested approaches are: commit or stash before switch branches. + The two suggested approaches are: one approach is to commit the changes before switch branches and the + 2nd option is to stash the changes. 4(A) done as described on Pycharm UI 5(A) No, it contains “a”, “b” and “c” @@ -75,12 +76,18 @@ Reset: ------------------------------------------------------------ 1(A) git checkout reset_question -2(A) 1. git reset --soft HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("9"). - The file "10" is uncommitted and is now in index (becomes green) and ready to be committed. - 2. git reset --mixed HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("8"). - The file "9" is uncommitted, the file "10" unindexed, both become red (untracked files). - 3. git reset --hard HEAD~1 --> Current commit is removed from project history, the HEAD is now the previous commit ("7"). - The file "8" uncommitted and removed. - 4. git revert HEAD~1 --> Delete the files from the previous commit (the file "6" is removed) and creates new commit with + +2(A) 1. git reset --soft HEAD~1 --> removes the last commit but the file changes will stay in your working tree. Also the changes will stay on your index + (The file "10" is uncommitted and is now in index) becomes green and is ready to be committed. The HEAD is now the previous commit ("9"). + + 2. git reset --mixed HEAD~1 --> removes the last commit from the current branch, changes in your working tree are kept but not on the index. + both "9" and "10" become red (untracked files) the HEAD is now the previous commit ("8") + + 3. git reset --hard HEAD~1 --> remove all (1) Uncommited changes, (2) Changes in the last commit, (3) Changes in the working tree + (you need to use git clean -df if you want to clear the untracked files manually). + The file "8" uncommitted and removed, the HEAD is now the previous commit ("7") + + 4. git revert HEAD~1 --> Delete the changes from the previous commit (the file "6" is removed) and creates new commit with this change. (HEAD is now the new commit). -3(A) HEAD~1 is the previous commit from the current HEAD. + +3(A) HEAD~1 is the previous commit from the current HEAD (HEAD~1 refers to the commit's first parent)