Here is the basic intro to git branching, aimed at users of other non-branch-based VCSes (I’m assuming you’re probably most familiar with CVS/SVN, based on when you were a CPython core dev).
To make this easier, you can add a git alias. I’ve created and tested one for you that will do a bunch of useful stuff for you to remove all the overhead of creating and pushing a new branch correctly. It syncs the latest remote changes, create a new branch off the latest clean upstream, switches to it and sets it up to automatically pull to and pull from a branch of the same name on your fork.
Here’s the command to add it (assuming you’re using some sort of bash-like shell, including the default Git Bash on Windows, as I use):
git config --global alias.new '!git fetch --all && git switch --no-track -c $1 upstream/main && git push -u origin'
You can call it with:
git new BRANCH-NAME
You can name it anything you want by changing alias.new
in the above to, e.g. alias.n
, which would be called by git n BRANCH-NAME
.
Using, say, the issue number as the BRANCH-NAME
(though I suggest making it more descriptive), for a one-commit change your workflow is now basically as easy as committing directly to main
and pushing that (much more so, if you count pulling/merging the current upstream main
first to make your changes off).
git n gh-106215
# Make your changes
git -a -m "Your commit message"
git push