Skip to content

Commit 42265da

Browse files
committed
differences for PR #5
1 parent 8cfe04b commit 42265da

4 files changed

Lines changed: 18 additions & 31 deletions

File tree

branches.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ exercises: 15
2525

2626
Branches are independent development lines. Working independently, you can likely get away with using git without creating any branches, as in the first diagram in the figure below. However, when you begin to work with others, branches allow team members to work on the code without impacting the work of other developers or users.
2727

28-
![Figure showing three graph diagrams representing different repository states. Each is a graph consisting of vertices (circles) and directed edges (arrows) where each horizontal path is a branch. The first shows a single path representing a repository with a single main branch, the second has two branches, a main and a feature branch, and the third has three branches, a main and two feature branches.](../fig/branches/branches.png){alt="" width="75%"}
29-
*These graph diagrams show repositories with different numbers of branches. The vertices, or circles, in these graphs show different commits, and each horizontal path is a branch. The first shows a repository with 1 main branch, the second a repository with 1 main and 1 feature branch, and the third repository 1 main and 2 feature branches.*
28+
![These graph diagrams show repositories with different numbers of branches. The vertices, or circles, in these graphs show different commits, and each horizontal path is a branch. The first shows a repository with 1 main branch, the second a repository with 1 main and 1 feature branch, and the third repository 1 main and 2 feature branches.](../fig/branches/branches.png){alt='Figure showing three graph diagrams representing different repository states. Each is a graph consisting of vertices (circles) and directed edges (arrows) where each horizontal path is a branch. The first shows a single path representing a repository with a single main branch, the second has two branches, a main and a feature branch, and the third has three branches, a main and two feature branches.' width="75%"}
3029

3130
Branches can have a few different purposes. Branches created to develop a specific feature are referred to as feature branches, and are often short-lived. Branches can also be used for longer-term purposes, such as having separate development and production branches. How you organize and use branches in your project is referred to as a branching strategy, which we will cover more when we talk about git workflows.
3231

@@ -51,11 +50,9 @@ git checkout -b my_new_branch
5150

5251
This will create the branch `my_new_branch` and move you to the new branch. If you run `git status` at this point it will display `On branch my_new_branch`. Making and committing any changes will only update `my_new_branch`.
5352

54-
![Figure showing the process of creating a branch. First a graph diagram of a repository is shown with two commits on the main branch. To the left is an arrow with the text "git checkout -b my_branch" followed by the same repository with the new feature branch added. A smiley face is used on each diagram to show where you are in the repository, the first has it on the second commit in the main branch, the second on the feature branch.](../fig/branches/create_branch.png){alt="" width="75%"}
55-
*Creating a new branch. When you run `git checkout -b my_branch` your new branch gets created and checked out, meaning you are now on your new branch (represented by the smiley face). Any commits you make will be on this branch until you checkout another one.*
53+
![Creating a new branch. When you run `git checkout -b my_branch` your new branch gets created and checked out, meaning you are now on your new branch (represented by the smiley face). Any commits you make will be on this branch until you checkout another one.](../fig/branches/create_branch.png){alt='Figure showing the process of creating a branch. First a graph diagram of a repository is shown with two commits on the main branch. To the left is an arrow with the text "git checkout -b my_branch" followed by the same repository with the new feature branch added. A smiley face is used on each diagram to show where you are in the repository, the first has it on the second commit in the main branch, the second on the feature branch.' width="75%"}
5654

57-
![Figure creating commits on a branch. First a graph diagram of a repository is shown with two commits on the main branch and one on a feature branch. To the left is an arrow with the text "git commit (x2)", followed by the same repository with to additional commits on the feature branch. A smiley face is used on each diagram to show where you are in the repository, each on the last commit on the feature branch.](../fig/branches/commit_branch.png){alt="" width="75%"}
58-
*Every time you run the `git commit` command the commit will be added to your current branch.*
55+
![Every time you run the `git commit` command the commit will be added to your current branch.](../fig/branches/commit_branch.png){alt='Figure creating commits on a branch. First a graph diagram of a repository is shown with two commits on the main branch and one on a feature branch. To the left is an arrow with the text "git commit (x2)", followed by the same repository with to additional commits on the feature branch. A smiley face is used on each diagram to show where you are in the repository, each on the last commit on the feature branch.' width="75%"}
5956

6057
The first time you push your branch to the remote repository, you will need to publish the branch by running run:
6158

@@ -75,8 +72,7 @@ git checkout main
7572

7673
Remember, if you aren't sure which branch you are on you can run `git status`. It is good practice before you start making changes to any of your files to check that you are on the right branch with `git status`, particularly if you haven't touched the code recently.
7774

78-
![Figure showing the process of changing, or checking out a branch. First a graph diagram of a repository is shown with two commits on the main branch and three on the feature branch. A smiley face is on the third commit of the feature branch to show the current location. To the left is an arrow with the text "git checkout main" followed by the same repository with the smiley face now on the second commit in the main branch.](../fig/branches/checkout_branch.png){alt="" width="85%"}
79-
*Switching branches using `git checkout`.*
75+
![Switching branches using `git checkout`.](../fig/branches/checkout_branch.png){alt='Figure showing the process of changing, or checking out a branch. First a graph diagram of a repository is shown with two commits on the main branch and three on the feature branch. A smiley face is on the third commit of the feature branch to show the current location. To the left is an arrow with the text "git checkout main" followed by the same repository with the smiley face now on the second commit in the main branch.' width="85%"}
8076

8177
### Merging Branches
8278

@@ -89,8 +85,8 @@ git merge main
8985

9086
will merge any changes introduced to `main` into the `my_new_branch`. Merging in this direction is especially useful when you've been working on `my_new_branch` for a while and `main` has changed in the meantime.
9187

92-
![Figure showing the process of merging the main branch into the feature branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits, and the main branch has an additional two commits after the split. A smiley face is on the third commit of the feature branch to show the current location. Below is an arrow with the text "git merge main" followed by the same repository with a new arrow from the last commit on the main branch to a new commit on the feature branch, showing the changes from the main branch have been merged into the changes on the feature branch.](../fig/branches/merge_into_branch.png){alt="" width="60%"}
93-
*Merging new commits from the main branch into the feature branch with `git merge main`.*
88+
![Merging new commits from the main branch into the feature branch with `git merge main`.](../fig/branches/merge_into_branch.png){alt='Figure showing the process of merging the main branch into the feature branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits, and the main branch has an additional two commits after the split. A smiley face is on the third commit of the feature branch to show the current location. Below is an arrow with the text "git merge main" followed by the same repository with a new arrow from the last commit on the main branch to a new commit on the feature branch, showing the changes from the main branch have been merged into the changes on the feature branch.' width="60%"}
89+
9490

9591
When development is complete on `my_new_branch`, it would be merged into `main`:
9692

@@ -99,17 +95,15 @@ git checkout main
9995
git merge my_new_branch
10096
```
10197

102-
![Figure showing the process of merging the feature branch into the main branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits. A smiley face is on the second commit of the main branch to show the current location. Below is an arrow with the text "git merge my_branch" followed by the same repository a new commit on the main branch with two arrows from the main and feature branches, showing the changes from the feature branch have been merged into main branch.](../fig/branches/merge_into_main.png){alt="" width="50%"}
103-
*Merging new commits the feature branch into the main branch with `git merge my_branch`.*
98+
![Merging new commits the feature branch into the main branch with `git merge my_branch`.](../fig/branches/merge_into_main.png){alt='Figure showing the process of merging the feature branch into the main branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits. A smiley face is on the second commit of the main branch to show the current location. Below is an arrow with the text "git merge my_branch" followed by the same repository a new commit on the main branch with two arrows from the main and feature branches, showing the changes from the feature branch have been merged into main branch.' width="50%"}
10499

105100
Git will do its best to complete the merge automatically. For example, if none of the changes have happened in the same lines of code, things will usually merge cleanly. If the merge can't complete automatically, this is called a merge conflict. Any conflicts in the files must be resolved before the merge can be completed.
106101

107102
## Merge vs Rebase
108103

109104
There is another way to introduce changes from one branch to another: rebasing. A rebase rewrites history. For example, if there are new commits on the main branch while you are working on a feature branch, you could merge those commits into your feature branch, as we describe above. This creates a new commit with two parent commits: one in your feature branch, one in the main branch. Alternatively, you can rebase your feature branch onto the new end of the main branch with `git rebase main`. Rebasing "replays" your feature branch commits onto the new commits of the main branch, as if you started your branch there.
110105

111-
![Figure showing the process of rebasing the feature branch onto new commits in the main branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits. A smiley face is on the third commit of the feature branch to show the current location. Below is an arrow with the text "git rebase main" followed by the same repository, but the feature branch now splits off the main branch at the last commit.](../fig/branches/rebase.png){alt="" width="50%"}
112-
*Rebasing the feature branch onto new commits in the main branch with `git rebase main`.*
106+
![Rebasing the feature branch onto new commits in the main branch with `git rebase main`.](../fig/branches/rebase.png){alt='Figure showing the process of rebasing the feature branch onto new commits in the main branch. First a graph diagram of a repository is shown with a main and feature branch. The feature branch with three commits splits off the main branch after two commits. A smiley face is on the third commit of the feature branch to show the current location. Below is an arrow with the text "git rebase main" followed by the same repository, but the feature branch now splits off the main branch at the last commit.' width="50%"}
113107

114108
Rebasing creates a cleaner history, without the extra merge commit. However, rebases never be done on public branches that others might be using or even looking at. It will result in your repository and everyone else's having different history, which can be confusing and difficult to fix. If no one else is looking at your branch, especially if you haven't published it yet, rebasing is safe.
115109

md5sum.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"index.md" "20a35cafbc108ef18c83f37ca98a0e3c" "site/built/index.md" "2025-06-16"
66
"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2025-06-16"
77
"episodes/introduction.md" "991e1cb69dd7e392f9ff5348fa6a1cdf" "site/built/introduction.md" "2025-06-16"
8-
"episodes/branches.md" "0bb82fecd9759fc34aa6f52643b0b3a8" "site/built/branches.md" "2025-06-16"
9-
"episodes/pr.md" "81271ff20c6d52e3f3db4740bef6fa85" "site/built/pr.md" "2025-06-16"
8+
"episodes/branches.md" "2b0d2dfc301d469acbeb29ce307c81f9" "site/built/branches.md" "2025-07-13"
9+
"episodes/pr.md" "3359da2f382ab34e6a6405d39efd2c3b" "site/built/pr.md" "2025-07-13"
1010
"episodes/git-workflows.md" "4b1183291501e5a535ef3ec78ba76272" "site/built/git-workflows.md" "2025-06-16"
1111
"instructors/instructor-notes.md" "cae72b6712578d74a49fea7513099f8c" "site/built/instructor-notes.md" "2025-06-16"
1212
"learners/reference.md" "9f1763bb4b44b2da6a2d5e9712bba822" "site/built/reference.md" "2025-06-16"
13-
"learners/setup.md" "4f6c609ec2d7a33704c4591113717825" "site/built/setup.md" "2025-06-16"
13+
"learners/setup.md" "4238af16f91642e843dcfecfcd77f347" "site/built/setup.md" "2025-07-13"
1414
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2025-06-16"

pr.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,25 @@ First, make sure you don't have any commits you haven't pushed to GitHub. Go to
3434

3535
Now navigate to your branch in GitHub. If you've pushed any commits recently you may see a callout that says your branch has recent pushes and provides a button that says "Compare and Pull Request". Pressing this will bring you to the form to create your Pull Request to the main branch. If you don't have this button, you can select "Pull Requests" at the top of the page and select "New Pull Request". From there select your branch under the "compare" dropdown. If you would like to merge your branch into a branch other than main, select that branch under the "base" dropdown. Then select "Create Pull Request".
3636

37-
![A screenshot of a branch on GitHub. A button with the text "Compare and Pull Request" is at the top fo the page.](../fig/pr/01_gotobranch.png){alt="" width="75%"}
38-
*Creating a Pull Request: If you recently pushed changes to your branch you may see a button that says "Compare and Pull Request" on GitHub.*
37+
![Creating a Pull Request: If you recently pushed changes to your branch you may see a button that says "Compare and Pull Request" on GitHub.](../fig/pr/01_gotobranch.png){alt='A screenshot of a branch on GitHub. A button with the text "Compare and Pull Request" is at the top fo the page.' width="75%"}
3938

4039
At this point you will see a form. Fill out the form with a title and description for the Pull Request, and then click "Create Pull Request". We will go more in depth on how to make good pull requests in a later section.
4140

42-
![A screenshot of a Pull Request form on GitHub.](../fig/pr/02_createpr.png){alt="" width="75%"}
43-
*Creating a Pull Request: Give your Pull Request a title and description.*
41+
![Creating a Pull Request: Give your Pull Request a title and description.](../fig/pr/02_createpr.png){alt='A screenshot of a Pull Request form on GitHub.' width="75%"}
4442

4543
### Anatomy of a Pull Request
4644

4745
Once the Pull Request is created there are a few different tabs on the page. The first is the conversation tab, which shows a timeline of comments and commits, starting with the initial description that you gave when creating the Pull Request. At the bottom will be a box that shows the result of any Continuous Integration that has been defined, such as automated tests (the one in the image doesn't have any set up), as well as whether there are any merge conflicts for the Pull Request.
4846

49-
![A screenshot of the conversation tab of a Pull Request.](../fig/pr/03_conversation.png){alt="" width="75%"}
50-
*The conversation tab of a Pull Request.*
47+
![The conversation tab of a Pull Request.](../fig/pr/03_conversation.png){alt='A screenshot of the conversation tab of a Pull Request.' width="75%"}
5148

5249
At the very bottom of the page is a box where you can leave a comment. GitHub supports markdown so you can include formatting with your comment.
5350

54-
![A screenshot of the bottom of the conversation tab of a Pull Request. At the bottom of the page is a box to leave a comment.](../fig/pr/04_comment.png){alt="" width="75%"}
55-
*The conversation tab of a Pull Request. Scroll to the bottom of the page to leave a comment.*
51+
![The conversation tab of a Pull Request. Scroll to the bottom of the page to leave a comment.](../fig/pr/04_comment.png){alt='A screenshot of the bottom of the conversation tab of a Pull Request. At the bottom of the page is a box to leave a comment.' width="75%"}
5652

5753
There is also a tab that shows all the commits in the Pull Request (the Commits tab). The last Files Changed tab shows the diff between the base branch and the Pull Request branch. This is useful in reviewing the Pull Request, and it allows you to leave in-line comments. If you see a line of code that needs to be updated or changed, you can click the + next to that line to leave a comment.
5854

59-
![A screenshot of the Files Changed tab of a Pull Request. The page shows one line of code has been updated.](../fig/pr/04_comment.png){alt="" width="75%"}
60-
*The Files Changed tab of a Pull Request, showing what the proposed changes are for the Pull Request. You can click the + next to a line number to leave an in-line comment.*
55+
![The Files Changed tab of a Pull Request, showing what the proposed changes are for the Pull Request. You can click the + next to a line number to leave an in-line comment.](../fig/pr/04_comment.png){alt='A screenshot of the Files Changed tab of a Pull Request. The page shows one line of code has been updated.' width="75%"}
6156

6257
### Updating a Pull Request
6358

@@ -67,8 +62,7 @@ Once the Pull Request is created you and anyone with access to the repository ca
6762

6863
Once a Pull Request has been reviewed and ready to be accepted, it can be merged. First verify that the branch has no conflicts with the base branch (the one that will be merged into). Any conflicts should be addressed with additional commits. When ready to merge, click "Merge Pull Request", then click "Confirm merge". You will be given the option to delete the branch. Whether you delete the branch depends on its purpose and how you and your group want to handle branches that have been merged. Deleting feature branches helps keep clutter down and makes it easier to find relevant branches. However, if you have any longer term branches, such as a development or production branch, you wouldn't want to delete that.
6964

70-
![A screenshot of the bottom of the conversation tab of a Pull Request after clicking "Merge Pull Request". There is a box with the original Pull Request title and description, with a button that says "Confirm Merge" below that.](../fig/pr/07_merge.png){alt="" width="75%"}
71-
*After clicking the "Merge Pull Request" button on the conversation, click "Confirm Merge" to merge the pull request.*
65+
![After clicking the "Merge Pull Request" button on the conversation, click "Confirm Merge" to merge the pull request.](../fig/pr/07_merge.png){alt='A screenshot of the bottom of the conversation tab of a Pull Request after clicking "Merge Pull Request". There is a box with the original Pull Request title and description, with a button that says "Confirm Merge" below that.' width="75%"}
7266

7367
## Activity
7468

0 commit comments

Comments
 (0)