These are the suggested exercises when using the flipped classroom method.
The key goal of the session is for the trainees to be able to use git/github to collaborate in the final project.
This exercise is about mimicking collaboration between two people on the same project. The workflow is the same that the trainees will use during the final project.
- create a repo named
git_exercise_1on github; - clone the repo you just created on github;
- on your computer, on the
mainbranch create the filefruits.txt, add the names of 3 fruits, one per line, and commit your changes; - push
mainto github; - on your computer, from
maincreate the branchfeature/fruitsand move to it; - on your computer, modify the name of the second fruit, add two new fruits at the end of the file (one per line), and commit your changes;
- on github, on branch
main, change the name of the second fruit in the filefruits.txt - update your local branch
feature/fruitswith the contents of the branchmainon github - push
feature/fruitsto github - create pull request to merge
feature/fruitsintomain
Note: the trainees will get a merge conflict on step 8.
The goal of this exercise is to learn how to get rid of a particular commit, that is not the latest commit.
- clone the repo: https://github.com/martamatos/cherry_pick_exercise.git
- in the branch add_fruits, get rid of the commit "added beetroots file". Hint: you need to create a new branch and use cherry-pick.
- in the branch add_veggies, get rid of the commit "added apples". Hint: You can either use one of the following approaches:
- create a new branch and use cherry-pick. (This one will lead to a conflict).
- use interactive rebasing on the branch. (This one will lead to a conflict).
Note: use git log --all --oneline to see all commits in all branches (the --oneline part is only to see a shorter version of the log).
This is about git revert and how you can get conflicts when you use it. The goal is that the trainees learn why sometimes they get conflicts when doing git revert and sometimes they don't.
- clone the repo: https://github.com/martamatos/revert_exercise.git
- revert the commit where file a was added.
- revert the commit where sweden was added. (This will lead to a conflict).
This exercise is about git stash (and reset or commit --amend)
- create a new repository on github called
git_exercise_4; - clone the repo you just created on github;
- create a new file in the repo called
project.txt; - write "Hello world!" on
project.txt, commit, and push the changes to the github; - create a new local branch
feature/new_sentenceand write "learning code" on the second line, commit, and push the branch to github; - on the local branch
feature/new_sentence, edit the second line to "learning code javascript" and save the file, do not commit; - move to main, you should get an error, remember you don't want to commit because your feature is not complete yet, but you still need to move to main;
- once you are on
main, you want to work on a different feature so create a new local branch namedfeature/new_number; - on branch
feature/new_number, add a new line with number 1 toproject.txt, commit, and push to github; - go to github and on the branch
feature/new_numberadd one more line with number 2 toproject.txt; - on your computer, add a new line with number 3 to
project.txtand save, do not commit; - pull the
feature/new_numberbranch (oh, what a message again! remember, you don't want to commit!); - finish the pull;
- check list of all stashes you have;
- go to
feature/new_sentencebranch, bring back the stash you did in this branch, push to github; - go to
feature/new_numberbranch, bring back the stash you did in this branch, solve the conflict and commit (do not push); - before you push
feature/new_numberto github you noticed a mistake in the commit message; - remove the commit, create correct commit message and push to github;
- your project is finished :)