Created: 4/12/2023
Note: I have a series of posts about git. For an intermediate workshop, see git some help.
This guide is mainly written with my Code the Dream (CTD) mentoring students in mind, but many bootcamp students or new open source contributors can benefit from these tips. First, when I say "GitHub Workflow," I mean the typical lifecycle of changes whereby an individual contributor gets their code into a git repository:
Note that this is the workflow at CTD is a bit different than your typical open
source workflow. Specifically, CTD students are branching from their own remote
repository, and simply applying self-imposed discipline to not commit to the
main
branch, as a way of rehearsing the way that the process works in most
companies.
Meanwhile in open-source repos, you cannot generally create a branch on the
real project repository. Instead, you make a branch of your own remote copy of
the project repo, then request to pull your changes into the upstream
repository from your remote repository. This is a more complex setup, and
not how it generally works at companies, which also why CTD does not teach
this workflow! However, if you are a CTD student and you've ever accidentally
made a pull request to merge your code into the CTD official clone of the
node_express_course
, this is why! GitHub is optimized for the open source
contributing workflow, where your personal fork is the "landing zone" for
changes ultimately bound for the repository you forked from. If you click the
default "create PR" button, it will target CTD by default!
OK, so what are these common mistakes we're going to address?
node_modules
or other stuff we don't wantLet's say it loud for those in the back:
You should be able to click 'merge' on your Pull Request!!!
And if you can't something's gone wrong!
For an example "bad" pull request, check out my own; #79. Technically, nothing is wrong here -- my intention is to actually contribute to code the dream, not to merge this code into the main branch of my own repository. But if you did this, it would be a mistake. You want your pull requests to target your own main branch!
You cannot change this PR to target the correct branch. You will need to close this PR and create a new one. First, let's create a new one; you can jump to the "week N" branch on your local repository by clicking on the blue chip on from the bad PR:
Next, you'll find yourself on the page for your branch. This is the branch you
made with your changes (typically "week2
" or similar). It looks like this,
and you should click contribute -> "Open Pull Request" to go onto the next
step:
Finally, we come upon the page where you done goofed the first time. There are 4 dropdowns, and you originally made a mistake by accepting the default value in the first one. By default, it'll prompt you to make a PR against Code The Dream's upstream repository, but you want to click that left-most dropdown, and change it to be your own repository!
That's it! Click "create PR," and you'll have a healthy PR. Don't forget to tell your reviewer where to look, and to close the PR you accidentally made against the Code the Dream repo!
WIP - will revisit!
WIP - will revisit!