A collaboration workflows with Git
Description
Apart from letting you track your changes over time in your individual projects, Git is also very powerful when it comes to collaboration with other people. In combination with a platform such as GitHub or Gitlab, you can seamlessly collaborate without losing the overview of your project.
This session will be about:
- Branching and merging with Git
- A collaboration workflow with GitHub
Check out the previous session if you missed it, where I talked about basic Git concepts and a simple Git workflow.
Tasks
The goal of these tasks is to get a feeling for a collaborative Git workflow.
If you are stuck in a task, you can have a look at the How-To description of the Git workflow with detailed explanations and screenshots of the steps.
Clone the cook book repo of your team mate (5 min)
Use GitHub Desktop to clone the cook book repository of your team mate.
Go to File -> Clone Repository.
In the tab “GitHub.com” you will find a list of all your repositories, including the ones where you are a collaborator. Find the repository of your team mate and clone it to a local path of your choice.
You can also clone a repository using its URL. Switch to the tab “URL” in GitHub Desktop. Open your team mate’s repository on GitHub (find the correct link here). On the GitHub page of the repo, click on the green code button on the top right, copy the HTTPS address and then paste it in the URL field of GitHub Desktop. Then clone it to a local path of your choice.
Open your team mate’s cook book in the explorer to see which files are already in there (Repository -> Show in Explorer).
Try branching and merging (10 min)
Make sure that you are in your team mate’s cook book (check which repository you are in on the top left).
Create a new branch to add a recipe (Branch -> New branch).
Make sure that you are now in the new branch by looking in the top middle of GitHub Desktop what your current branch is:
Now go to the project folder (Repository -> Show in Explorer) and add a file for a new recipe.
You can again copy paste a recipe from below to save some time.
Ingredients:
2 ripe bananas
2 large eggs
120 g all-purpose flour
240 ml milk
1 tsp baking powder
1 tsp vanilla extract
1 tbsp sugar
Pinch of salt
Butter or oil for cooking
Preparation:
Mash bananas and mix with eggs, milk, and vanilla.
Combine flour, baking powder, sugar, and salt.
Mix dry ingredients into wet ingredients until smooth. Cook on a heated pan with butter or oil until golden brown.
Ingredients:
200 g ramen noodles
1 liter chicken broth
2 cloves garlic, minced
1 tbsp ginger, minced
2 tbsp soy sauce
1 tbsp miso paste
2 large eggs
100 g mushrooms, sliced
1 carrot, julienned
100 g spinach
2 green onions, sliced
1 tbsp sesame oil
Salt and pepper to taste
Preparation:
Cook ramen noodles according to package instructions, drain and set aside.
In a pot, heat sesame oil and sauté garlic and ginger until fragrant.
Add chicken broth, soy sauce, and miso paste, and bring to a simmer.
Add mushrooms and carrot, cook until tender.
In a separate pot, boil eggs for 7 minutes, then cool, peel, and halve.
Add spinach to the broth and cook until wilted.
Divide noodles into bowls, pour broth and vegetables over them.
Top with halved eggs and sliced green onions. Season with salt and pepper to taste.
Ingredients:
240 g all-purpose flour
200 g grated carrots
300 g sugar
240 ml vegetable oil
4 large eggs
1 tsp baking powder
1 tsp baking soda
1 tsp ground cinnamon
0.5 tsp ground nutmeg
0.5 tsp salt
1 tsp vanilla extract
Preparation:
Beat eggs and sugar, add oil and vanilla.
Mix flour, baking powder, baking soda, cinnamon, nutmeg, and salt.
Combine wet and dry ingredients, fold in carrots. Bake at 175°C for 35-40 minutes.
Ingredients:
450 g chicken breast, cubed
1 large onion, chopped
3 cloves garlic, minced
1 tbsp ginger, minced
400 ml coconut milk
400 g diced tomatoes
2 tbsp curry powder
1 tsp turmeric
1 tsp cumin
1 tsp coriander
Salt and pepper to taste
2 tbsp vegetable oil
Fresh cilantro for garnish
Preparation:
Sauté onion, garlic, and ginger in oil.
Add spices and chicken, cook until browned.
Add tomatoes and coconut milk, simmer until chicken is cooked. Season with salt and pepper, garnish with cilantro.
Ingredients:
250 g all-purpose flour
150 g sugar
150 g brown sugar
225 g butter, softened
2 large eggs
1 tsp vanilla extract
1 tsp baking soda
0.5 tsp salt
300 g chocolate chips
Preparation:
Preheat oven to 175°C.
Cream together butter, sugar, and brown sugar.
Add eggs and vanilla, mix well.
Combine flour, baking soda, and salt.
Gradually add dry ingredients to wet ingredients.
Fold in chocolate chips.
Drop spoonfuls of dough onto a baking sheet. Bake for 10-12 minutes until golden brown.
Ingredients:
200 g cherry tomatoes, halved
1 cucumber, diced
1 red onion, thinly sliced
1 green bell pepper, diced
100 g feta cheese, crumbled
50 g black olives
2 tbsp olive oil
1 tbsp red wine vinegar
1 tsp dried oregano
Salt and pepper to taste
Preparation:
Combine tomatoes, cucumber, onion, bell pepper, feta, and olives in a bowl.
Whisk together olive oil, vinegar, oregano, salt, and pepper.
Pour dressing over salad and toss to combine. Serve immediately.
Add and commit that new recipe to your branch.
Now switch back to the main branch (click on the “current branch” button on top and select “main”).
Merge your new branch into the main branch (Branch -> Merge into current branch -> select your branch). Now check the commit history to see if your branch commit is actually there.
Now push the “main” to GitHub by clicking the push button to share your changes with your team mate.
Extra
- Switch back to your branch and work on the recipe
- Change and add things and make some more commits
- When you are done, merge the branch into the main branch again
- Push the main branch to GitHub
Make a pull request in your team mate’s repo (10 min)
Now it’s again time to modify something in your team mate’s cook book. Make sure you are in your team mate’s repository on the top left of GitHub desktop.
Create another branch and make some changes
Create another branch (Branch -> New branch) and make sure that you are on that branch (top middle section of GitHub Desktop).
Make some changes
Open a file in your team mate’s cook book and make some changes. Save and close the file and switch to GitHub Desktop.
Now commit these changes.
Publish and push branch
Publish and push your branch to GitHub by clicking on the publish/push button.
Pull request
Now open the repository on GitHub (Repository -> View on GitHub). On top you should already see the option to “Compare and pull request”:
Click on that button and use the dialogue window that opens to describe your changes. Then create the pull request by clicking on the green button that says “Create pull request”.
For the fast ones
As long as the pull request is not merged, you can still make changes to your branch and push them to GitHub. The pull request will automatically update with the new changes. So you can now switch to your machine again, make sure that in GitHub Desktop you are still on your branch and make some more changes to repository. Commit and push the changes to GitHub.
Review pull request on your repo
Now it’s time to look at the pull request your team mate left in your repository and decide if you want to merge it or not.
When you have a pull request, you can see it on top, indicated by the number next to the pull request button:
Open the pull request by clickon on the button and selecting the Pull request from the list of pull requests.
Click through the tabs on top. E.g. the “Files changed” tab is very interesting.
You can comment on the pull request if you want and ask for changes.
When you are happy, you can merge the pull request by clicking on the green “Merge pull request” button:
Now the changes are integrated into the main branch.