|
| 1 | +# Exercises - Basic Commands |
| 2 | + |
| 3 | +## Try out the basic commands |
| 4 | + |
| 5 | +The purpose of this exercise is to learn about basic commands further. |
| 6 | + |
| 7 | +1. Create a folder called "mysecondrepo" which will contain your repository. |
| 8 | +Tasks: |
| 9 | + - initialize the repository |
| 10 | + - create a README.md file and add this text on the first line: "File created on Sep. 30, 2020" |
| 11 | + - stage the file |
| 12 | + - commit the changes |
| 13 | + - create a second file "Poem.md" without any text (hint: use touch command), stage and commit it |
| 14 | + |
| 15 | +2. Copy and paste the two paragraphs below of the poem *la lluvia* by Jorge Luis Borges into the Poem.md file: |
| 16 | +Tasks: |
| 17 | + - stage the first paragraph only |
| 18 | + - confirm that the file has been partially staged by checking the status. |
| 19 | + - check if the staged changes correspond to just the first paragraph by looking at the differences between: |
| 20 | + -- the working directory vs. the staging area |
| 21 | + -- the staging area vs. the committed changes region (Repo) |
| 22 | + - commit the staged changes and check the status |
| 23 | + - stage the second paragraph and commit the changes |
| 24 | + |
| 25 | +<pre><code> |
| 26 | +Bruscamente la tarde se ha aclarado |
| 27 | +Porque ya cae la lluvia minuciosa. |
| 28 | +Cae o cayó. La lluvia es una cosa |
| 29 | +Que sin duda sucede en el pasado. |
| 30 | + |
| 31 | +Quien la oye caer ha recobrado |
| 32 | +El tiempo en que la suerte venturosa |
| 33 | +Le reveló una flor llamada rosa |
| 34 | +Y el curioso color del colorado. |
| 35 | +</code></pre> |
| 36 | + |
| 37 | +3. Create a folder called "FirstPoem" and move the Poem.md file to this new folder (use git mv). |
| 38 | +Check the status to confirm that the file was moved. Commit the changes. |
| 39 | + |
| 40 | +4. (Challenge task) Add the next paragraph of the poem: |
| 41 | + |
| 42 | +<pre><code> |
| 43 | +Esta lluvia que ciega los cristales |
| 44 | +Alegrará en perdidos arrabales |
| 45 | +Las negras uvas de una parra en cierto |
| 46 | + |
| 47 | +Patio que ya no existe. La mojada |
| 48 | +Tarde me trae la voz, la voz deseada, |
| 49 | +De mi padre que vuelve y que no ha muerto. |
| 50 | +</code></pre> |
| 51 | + |
| 52 | +stage the changes and commit them. Now, we have the last four commits refering to the same topic (same poem). |
| 53 | +The goal of this part of the exercise is to summarize those four commits into a single one. |
| 54 | + |
| 55 | +hint: git rebase -i HEAD~4 |
| 56 | + |
| 57 | +5. End of exercise |
| 58 | + |
| 59 | +## git diff usage |
| 60 | + |
| 61 | +The purpose of this exercise is to show you the usage of the *git diff* command. |
| 62 | + |
| 63 | +1. Create a folder called "myfirstrepo" which will contain your repository. |
| 64 | +Tasks: |
| 65 | + - initialize the repository |
| 66 | + - create a README.md file and add this text on the first line: "File created on Sep. 30, 2020" |
| 67 | + - stage the file |
| 68 | + - commit the changes |
| 69 | + |
| 70 | +At this point, your working directory, the staging area, and the local repository |
| 71 | +(committed changes) are all synchronized. |
| 72 | + |
| 73 | +2. Make a change to the README.md file by adding a line with the string "TODO list". Now, the |
| 74 | +staging area and the local repository are synchronized with each other but the working |
| 75 | +directory is not synchronized with them. |
| 76 | + - check the differences between the working directory and the staging area |
| 77 | + (hint: git diff) |
| 78 | + - check the differences between the working directory and the local repository |
| 79 | + (hint: git diff HEAD) |
| 80 | + |
| 81 | +confirm that the changes correspond to what you expected by looking at the diff outputs. |
| 82 | + |
| 83 | +3. Add the file README.md to the staging area. Now, the working directory and the staging area |
| 84 | +are synchronized with each other but they are not synchronized with the local repository. |
| 85 | + - check the differences between the staging area and the local repository |
| 86 | + (hint: git diff --staged) |
| 87 | + - check the differences between the working directory and the local repository |
| 88 | + (hint: git diff HEAD) |
| 89 | + |
| 90 | +confirm that the changes correspond to what you expected by looking at the diff outputs. |
| 91 | + |
| 92 | +4. Make an additional modification to the README.md file by adding a line with the string |
| 93 | +"Add the support email". Now, all the three areas working directory, the staging area |
| 94 | +and the local repository are not synchronized with each other. |
| 95 | + - check the differences between the working directory and the staging area |
| 96 | + (hint: git diff) |
| 97 | + - check the differences between the staging area and the local repository |
| 98 | + (hint: git diff --staged) |
| 99 | + - check the differences between the working directory and the local repository |
| 100 | + (hint: git diff HEAD) |
| 101 | + |
| 102 | + |
| 103 | +confirm that the changes correspond to what you expected by looking at the diff outputs. |
| 104 | + |
| 105 | +5. End of exercise |
| 106 | + |
0 commit comments