not logged in | [Login]
As a starting point, I have the following:
git remote add upstream https://github.com/micropython/micropython.git
Now sometimes I just hack on the "tve" branch, sometimes I create a feature branch from the outset, but in both cases I often end up with changes I want to put into a PR and with changes I don't (they either belong to something else or they're debug statements I don't want to delete yet but that shouldn't be in the PR). Here's what I typically do:
git fetch upstream
and then create my branch with git checkout -b my-feature upstream/master
git checkout -p hack-branch
and go through the interactive flow (a tall terminal window helps!)git commmit -a -m "message"
, if you want to review what you're adding (recommended unless you didn't do anything but the checkout -p) use git add -pi
and go through the interactive flow.git push -u origin my-feature
(if you just type git push
git will print what you should have typed)Usually things don't go as cleanly as above... Some tips:
git checkout -p
you can split hunks using 's' to separate lines you want included from ones you don't, you can even use an editor ('e') to hand-edit a hunk, for example, to delete "+" lines that add debug code you don't wantgit stash
to save what you have done; git checkout hack-branch
; edit away; git checkout
my-featureto come back,
git stash applyto get the changes you already pulled over back, and then another
git checkout -p hack-branch`Down the road, reviewers of course will ask you to make changes to your PR. I find that cherry-pick
is my best friend here. The idea is to make the changes in the hack-branch or the my-feature branch and then cherry-pick into the other to keep them in sync:
git checkout hack-branch
and hack awaygit add -pi
to add just the changes you want into a commit, then git commit -m "message"
, copy the SHA which commit prints (something like [hack-branch 66486f9c3]
where 66486f9c3
is the beginning of the SHA and all you need)git checkout my-feature; git cherry-pick 66486f9c3
git push
Last edited by Thorsten von Eicken, 2020-04-29 18:01:32