Leave a rating/review
In the last video, you saw how to push your changes to your branch. If you open up your repository, you can see that because you are on the “Carnitas Tacos Recipe” branch, you have the Carnitas Tacos recipe. Switch to the main branch. This branch does not have the commit you created on the “Carnitas Tacos Recipe” branch. Open up the repo. You can see here that, just like what’s shown in the GitHub app, you don’t have the “carnitas-tacos.txt” file for the Carnitas Tacos recipe.
So, how do you get those commits into the main branch?
First, it can help to visualize the commit graph again. The project looks like this, where you have the first three commits before creating the new branch. Those commits are on main, denoted by the dotted line. Main is still on this commit.
In the last video, when you created a new recipe on the new “Carnitas Tacos Recipe” branch, you added a new commit here. This commit does not exist on the main branch. You need to perform a “merge,” as Git calls it, to merge it into the main branch.
In the GitHub Desktop app, let’s compare the two branches to make sure we want to bring those changes in. Go to Branch > Compare to Branch. Here, on the left, the GitHub app is asking what branch to compare to. Select the “Carnitas Tacos Recipe” branch. The app shows that your current branch, main, is one commit behind the “Carnitas Tacos Recipe” branch, and this is what’s in the commit. In order to pull those changes into your main branch, you can now create a merge commit here. This creates a new commit on the main branch with the changes from the “Carnitas Tacos Recipe” branch.
If you now hit the X button, you can see that the main branch now has that change. And if you open up your working directory, you’ll also see the “carnitas-tacos.txt” file.
Open a web browser to your repo. On the main branch, you can click on “Commits” and see that there are still only 3 commits, and your Carnitas Tacos recipe isn’t there. That’s because your changes are only still local. You still need to push your changes like you did in previous videos.
Click “Push origin.” Go back to your web browser and refresh the browser. Now you can see the new commit on the main branch in your remote repo.
Now, your commit graph looks like this: both the main label and “Carnitas Tacos Recipe” label point to the same commit.