-
-
Notifications
You must be signed in to change notification settings - Fork 945
Add episode on branching #1083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add episode on branching #1083
Conversation
🆗 Pre-flight checks passed 😃This pull request has been checked and contains no modified workflow files, spoofing, or invalid commits. It should be safe to Approve and Run the workflows that need maintainer approval. |
In this lesson, Alfredo is trying to run an analysis | ||
and doesn't know if it will be faster in bash or python. | ||
To keep his main branch safe he will use separate branches | ||
for both bash and python analysis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to keep the "flavour" of Alfredo as a chef keeping his recipes under version control. So perhaps we could say he's experimenting with a new version of his famous strawberry cream cake in which he uses mango and less sugar, or something of the kind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it goes this way, then the whole content should be adapted accordingly. A possibility would be something like he wants to experiment on his current cake recipe, and change the type of flour and also the type of sweetening. So he creates only one branch of a variant of the cake. Where he removes the old ingredients and adds the new ones. And then he wants to compare the cake to his previous version so he switches to main branch and prepares the other cake (the students will see the changes in the recipe file immediately having effect inplace). Then he decides that the new recipe is better, so he merges the changes of the new branch to main. It's basic but it's also in the "flavour" you mention, and it's possible to see an advantage of branching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty much what I would suggest. But I think we need a good discussion on whether to do one branch or two branches, I'm not certain of my opinion.
To switch to our new branch we can use the `checkout` command | ||
we learned earlier and check our work with `git branch`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been changed, and we now try not to use checkout
. The command we can use to move to another branch is git switch
. We should teach that, even if it's newer, because checkout
does many things and is confusing to beginners.
Before we used the `checkout` command to checkout a file from a specific commit | ||
using commit hashes or `HEAD` and the filename (`git checkout HEAD <file>`). The | ||
`checkout` command can also be used to checkout an entire previous version of the | ||
repository, updating all files in the repository to match the state of a desired commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: checkout
is no longer taught in this lesson, so this is not relevant any more. The comparison can be done with git restore
if needed.
For simplicity, we will `touch` the script making an empty file | ||
but imagine we spent hours working on this python script for our analysis. | ||
|
||
```bash | ||
$ touch analysis.py | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make an experimental edit to an existing recipe instead.
git branch -D bashdev | ||
``` | ||
|
||
```output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the ending (usually each episode has a summary at the end)
Thank you so much @davidwilby! I've left comments inline above. Summarizing and adding more general thoughts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added inline comments and answers to comments to attempt a more "in flavour" approach. Also, I propose to add a merge conflict example and solution, because it is something they will need to do quite early on their git experience with branches.
@@ -0,0 +1,329 @@ | |||
--- | |||
title: Branches | |||
teaching: 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite sure this can take 25 to 30 minutes. Also, I believe it important to give them an exercise to try it out themselves, because it's something that can be confusing and just trying it allows to fully understand what one is doing. maybe 5 to 10 for exercises?
So far we've always been working in a straight timeline. | ||
However, there are times when we might want to keep | ||
our main work safe from experimental changes we are working on. | ||
To do this we can use branches to work on separate tasks in parallel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can branch our timeline to work on separate tasks in parallel
I'm in". | ||
|
||
```bash | ||
$ git merge pythondev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that one of the most complicated actions that a novice user of git needs to handle quite early is merge conflicts. In this case, everything works, but I thin it would make sense to make a merge conflict example where Alfredo needs to solve it, so that not only it is documented in the content on how to solve conflicts, but also the students understand the workflow of solving merge conflicts. What do you all think of adding this to the content?
In this lesson, Alfredo is trying to run an analysis | ||
and doesn't know if it will be faster in bash or python. | ||
To keep his main branch safe he will use separate branches | ||
for both bash and python analysis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it goes this way, then the whole content should be adapted accordingly. A possibility would be something like he wants to experiment on his current cake recipe, and change the type of flour and also the type of sweetening. So he creates only one branch of a variant of the cake. Where he removes the old ingredients and adds the new ones. And then he wants to compare the cake to his previous version so he switches to main branch and prepares the other cake (the students will see the changes in the recipe file immediately having effect inplace). Then he decides that the new recipe is better, so he merges the changes of the new branch to main. It's basic but it's also in the "flavour" you mention, and it's possible to see an advantage of branching.
This draft PR is intended as a starting point for discussion on this topic as requested in #1022
I've added the episode on branches from https://github.com/carpentries-incubator/git-novice-branch-pr/ more or less verbatim albeit with name and format changes to match the new narrative. This is just added as
06b-branches.md
for now to avoid complicating the diff by changing all the other file numbers but showing where it would fit into the order.Points of discussion:
Looking forward to a lively discussion on this and thanks for the opportunity to contribute!