diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b535806d66f2086f83b98804e354fddf2cb3c92f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 git-sandbox + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 4eab5600a25fdeb21fcbf610fc0ba3deff984581..982e267135059d8e615a459ece8e247f7855481c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,132 @@ # shopping-list -Simple repository to practise git basics on a shopping list \ No newline at end of file +Simple repository to practise git basics on a shopping list. Simply add things on the list by editing the list.txt file on a repository you will have cloned. Then commit, push things on the remote repo and check the result on the gitlab interface. + + + +Exercices +========= + +Creating the project +-------------------- + +1. Fork the project on the web interface. 1 fork per group and all group members should be member of the forked git repo. + +2. Each group member clones the project on his/her laptop + +Looking at diffs +---------------- +1. Modify list.txt of your working copy and try + ``` + git status + git diff + git diff --staged + ``` + +2. Add this file to the staging area and try + ``` + git status + git diff + git diff --staged + ``` + +3. Remove the file from the staging area (*reset*, Hint: the command is shown in the output of git status). +4. Then cancel your modification by asking git to overwrite the modified file with the latest version of the repository. +``` +git checkout master -- list.txt +``` + +Working on the same branch +-------------------------- + +1. Fast forward merges +On the master branch, for each group of students: + * student1 modifies list.txt, commits and pushes + ``` + vim list.txt + git commit + git push origin master + ``` + * student2 pulls, modifies list.txt, commits and pushes + ``` + git pull origin master + vim list.txt + git commit + git push origin master + ``` + * student3 pulls, modifies list.txt, commits and pushes + ``` + git pull origin master + vim list.txt + git commit + git push origin master + ``` + +2. Merges +On the master branch, for each group of students: + * everybody modifies list.txt, but a **different line** + * everybody tries to commit & push + +3. Conflict +On the master branch, for each group of students: + * student1 and student2 modify **the same line** in list.txt + * everybody tries to commit & push + +Feature branch & merge request +------------------------------ +1. Protected branch + * On the web interface, modify the access property of the master branch to *protected* status (settings/Repository/protected branches) + * Student1 creates a new commit on the master branch + * Try to push this new commit on the gtilab server on the master branch. + * What happens ? + +2. Feature branch + * Student1 creates a new branch (`git branch branch_name`) such that the latest commit belongs to the new branch and not anymore to the master branch + * Student1 pushes his new branch on the server (`git push origin branch_name`) + * Student2 creates a new branch from master directly (`git checkout -b branch_name2`) + * Student2 creates a new commit on this new branch and pushes the branch on the server + +3. Merge request + * On the web interface each student creates a merge request to merge their feature branch to the master one + * Accept it and verify it gives the correct result + +Setting and fixing issues +------------------------- +1. Each student creates a new feature branch like before and pushes it on the server + +2. Reporting an issue + * On the web interface, report an issue on the branch of your colleague + * Discuss on the issue using the web interface + +3. Fixing the issue + * Each student fixes the issue in his own branch + * Change the status of the issue by providing the appropriate commit message by mentioning `Fix #2` to close issue number 2 for example. Please refer to [gitlab documentation](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html) for all possible ways to open and close issues. + +Exploring the history +--------------------- +1. Try to answer the following questions + * Who touched this line from this file ? + * Who modified this part of the reopsitory during a given period ? + * To which branch does this commit belong ? + * ... + +2. If you managed to answer some questions, show the others how you managed to do it + +Stashing modifications +---------------------- +1. Stash modifications + * Modify the local copy of a branch + * You cannot checkout another branch right now. You have to *save* your modification without creating a proper commit, i.e. to *stash* them with `git stash`. + * Checkout the other branch + * Modify it and commit + +2. Unstash your modifications + * Checkout the inital branch again + * unstash your modfications with `git stash pop` + * You recover the state you were before + +Multiple remote repositories +--------------------- +1. Add the project of another group of students as a new remote of your local repository +2. Try to merge something and see what happens... + diff --git a/git.pdf b/git.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4840aa124752e0d89dc2e49db98e5e9174070795 Binary files /dev/null and b/git.pdf differ diff --git a/list.txt b/list.txt new file mode 100644 index 0000000000000000000000000000000000000000..3ce58378cbd5801846c65da509838faa144aee70 --- /dev/null +++ b/list.txt @@ -0,0 +1,2 @@ +[x] tomatoes +[ ] potatoes