Posts

Showing posts from December, 2021

Conclusion

It’s been an adventure, ladies and gentlemen. From a starting point at ground zero, we now know how to perform all the basic Git repository tasks: cloning to the local machine, making commits, pushing to and pulling from the remote repository, and merging code from one branch onto another. We’ve also looked at more advanced tasks like rebasing unpublished branches and cherry-picking commits from one branch onto another in order to make urgent changes before the rest of the branch’s code is ready to be merged. In exploring the cherry-picking process, we also saw that Git is not infallible, and we followed that by touching briefly on how to intervene manually when Git cannot merge changes by itself. One area of Git that I specifically did not touch on in the past few weeks was carrying out all of these tasks via the command line. Many in the industry would argue that, by choosing to avoid the command line, I have not taught you anything about how to use Git in a real-w...

Merge Conflicts

Image
As you’ll recall from the last post, when we tried to cherry-pick our bug fix from the feature branch into the main, Git wasn’t sure what we wanted the finished file to look like and forced us to tell it ourselves. That shouldn’t have happened in the particular situation we dealth with last time, but today, we’ll be looking at situations where we would actually expect that to occur. Merge Conflicts When moving code from one branch of a repository to another, a merge conflict occurs when there have been commits to both branches that change the same line of the same file since the last time the branches were synced with each other. In this situation, Git needs to be told which version of that line you want to keep in the final result. Log into GitHub.com and create a new private repo initialized with a README file. The README will be initialized with a heading containing the name of your new repo. After creating the repo, click the pencil in the top-right co...

Cherry-Picking

Image
We’ve now dealt with two ways to move code from one branch of a Git repository to another: merging and rebasing. Both merging and rebasing transfer all of the code currently on the source branch to the destination branch, which is not always desirable. To move only some of the source branch’s code to the destination branch, we use a procedure called cherry-picking . No one found the bug from last week’s program, which doesn’t surprise me since it’s a subtle one. The bug is actually twofold, and both aspects have to do with how the Tkinter GUI toolkit handles modifier keys. The first aspect of the problem is that the keybinding Alt-c is only triggered when the focused window receives a lowercase c . If the user has Caps Lock on, pressing Alt and the C key will send a capital C , and the keybinding will not trigger. Open GitHub Desktop to the add-counter branch of the rcp-demo repository we were working in last week, and open the file helloWorldGUI.py i...