From 15aa0613e26696c17035244d3421c3dee6d4b6c7 Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 21 May 2022 11:24:29 +0300 Subject: [PATCH] git exercise daniel malka --- 07_git_exercises/1.txt | 1 + 07_git_exercises/10.txt | 1 + 07_git_exercises/2.txt | 1 + 07_git_exercises/3.txt | 1 + 07_git_exercises/4.txt | 1 + 07_git_exercises/5.txt | 1 + 07_git_exercises/6.txt | 1 + 07_git_exercises/7.txt | 1 + 07_git_exercises/8.txt | 1 + 07_git_exercises/9.txt | 1 + 07_git_exercises/abc.txt | 3 ++ 07_git_exercises/danielmalka_ex1/README.md | 49 ++++++++++++++++++++++ 12 files changed, 62 insertions(+) create mode 100644 07_git_exercises/1.txt create mode 100644 07_git_exercises/10.txt create mode 100644 07_git_exercises/2.txt create mode 100644 07_git_exercises/3.txt create mode 100644 07_git_exercises/4.txt create mode 100644 07_git_exercises/5.txt create mode 100644 07_git_exercises/6.txt create mode 100644 07_git_exercises/7.txt create mode 100644 07_git_exercises/8.txt create mode 100644 07_git_exercises/9.txt create mode 100644 07_git_exercises/abc.txt create mode 100644 07_git_exercises/danielmalka_ex1/README.md diff --git a/07_git_exercises/1.txt b/07_git_exercises/1.txt new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/07_git_exercises/1.txt @@ -0,0 +1 @@ +1 diff --git a/07_git_exercises/10.txt b/07_git_exercises/10.txt new file mode 100644 index 00000000..f599e28b --- /dev/null +++ b/07_git_exercises/10.txt @@ -0,0 +1 @@ +10 diff --git a/07_git_exercises/2.txt b/07_git_exercises/2.txt new file mode 100644 index 00000000..0cfbf088 --- /dev/null +++ b/07_git_exercises/2.txt @@ -0,0 +1 @@ +2 diff --git a/07_git_exercises/3.txt b/07_git_exercises/3.txt new file mode 100644 index 00000000..00750edc --- /dev/null +++ b/07_git_exercises/3.txt @@ -0,0 +1 @@ +3 diff --git a/07_git_exercises/4.txt b/07_git_exercises/4.txt new file mode 100644 index 00000000..b8626c4c --- /dev/null +++ b/07_git_exercises/4.txt @@ -0,0 +1 @@ +4 diff --git a/07_git_exercises/5.txt b/07_git_exercises/5.txt new file mode 100644 index 00000000..7ed6ff82 --- /dev/null +++ b/07_git_exercises/5.txt @@ -0,0 +1 @@ +5 diff --git a/07_git_exercises/6.txt b/07_git_exercises/6.txt new file mode 100644 index 00000000..1e8b3149 --- /dev/null +++ b/07_git_exercises/6.txt @@ -0,0 +1 @@ +6 diff --git a/07_git_exercises/7.txt b/07_git_exercises/7.txt new file mode 100644 index 00000000..7f8f011e --- /dev/null +++ b/07_git_exercises/7.txt @@ -0,0 +1 @@ +7 diff --git a/07_git_exercises/8.txt b/07_git_exercises/8.txt new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/07_git_exercises/8.txt @@ -0,0 +1 @@ +8 diff --git a/07_git_exercises/9.txt b/07_git_exercises/9.txt new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/07_git_exercises/9.txt @@ -0,0 +1 @@ +9 diff --git a/07_git_exercises/abc.txt b/07_git_exercises/abc.txt new file mode 100644 index 00000000..01e79c32 --- /dev/null +++ b/07_git_exercises/abc.txt @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/07_git_exercises/danielmalka_ex1/README.md b/07_git_exercises/danielmalka_ex1/README.md new file mode 100644 index 00000000..f202a289 --- /dev/null +++ b/07_git_exercises/danielmalka_ex1/README.md @@ -0,0 +1,49 @@ +# Git Basics: +1. echo "1" > abc.txt +2. red +3. after git add command on abc.txt - the color changed to green +4. echo "2" >> abc.txt +5. the color changed to red again (using git status command) +6. use the command git diff +7. because we did not add the changes in abc.txt to the index +8. because there is no branch called stage2 +9. git add abc.txt +10. still does not show differences since we did not commit the change yet +11. git diff --cached +12. echo "3" >> abc.txt +13. git diff --staged shows "2" added to the file while git diff main shows that "3" has also added to the file since we did not commit anything yet. +14. once green for when we added "2" to the index, second red for not staged change "3" +15. use git reset + +# Resolve Conflicts: +1. list all existing branches using git branch -a +2. create and switch to the new branch: git checkout -b feature/lambda_migration +3. merge feature/version1 to feature/lambda_migration and observe the merged changes using: git merge feature/version1 +4. using PyCharm - select git > merge > feature/version2 +5. select app.py and click merge > click on all to show all files > use annonate git blame on both version and accept left (port 8081) +6. there is no added commits after completing with merges + +# Cherry Picking +1. first switch to main: git checkout main then create a clean branch: git checkout -b feature/lambda_migration2 +2. git tab > log > double click on lambda_migration +3. select reconnect() commit and click on cherry-picking, then on restrict extensions and click on cherry-picking +4. two files: app.py and config.json +5. the cherry-picking order matters since if we will go back to an older commit the newer will not be available + +# Changes in the working tree and switch branches +1. git branch -a shows we are in feature/lambda_migration2 +2. create a new file: echo "newfile" > take.txt then add it to the index git add take.txt +3. the error we got is because we didn't commit take.txt, there are 2 approaches - to commit the changes or stash them. to stash a change is to temporarily save it without the need to commit it, so you can work on another branch and get back to it later. +4. select git > branches > dev > force checkout +5. no +6. force checkout let you switch to another branch even if you did not stage your changes but makes a local copy of the file. + +# Reset +1. use the command: git checkout reset_question +2. commands: +a. git reset --soft HEAD~1 - undo the last commit (paint 10 in green) without touching the index file or the working tree +b. git reset --mixed HEAD~1 - change 10 and 9 to red - resets also the index but not the working tree +c. git reset --hard HEAD~1 - resets also the index and the working tree to a certain commit +d. git revert HEAD~1 - reverse the effect of HEAD~1 commit +3. HEAD~1 refers to a previous commit +