so, I've decided to always start personal commits with --p: and made some git aliases:
but I can't predict the future: which changes won't be wanted?
I found a way to mark them AFTER.
MARKING AFTER
If you have unwanted changes that span many commits, or are inside useful commits
- remove your personal changes
- commit
- git revertP
revertP
reverts the last commit and starts the revert message with --p:
revertP = "!HEADID=$(git rev-parse HEAD) && git revert --no-commit HEAD && git commit -m \"--p: revert\" -m \"This reverts commit $HEADID.\" #"
the actual message is:
--p: revert
This reverts commit $HEADID.
if you want to mark a past commit
- git revertID <commit>
revertID
self-explanatory (you really should understand the commands before running them)
revertID = "!git revert --no-edit $1 && git revertP #"
examples: git revertID 0d299bd2, git revertID "HEAD^5"
DROPPING
drop
drop all commits starting with --p:: BEWARE, this works on your CURRENT branch
drop = "!GIT_SEQUENCE_EDITOR=\"sed -i '/^pick .\\{7\\} --p:/  s/^pick/drop/'\" git rebase -i --root #"
(I guess rebasing from root is inefficient but faster than specifying the starting point)
generate
takes the 1st command line argument (name of the PR branch)
generate = "!CURRENT=$(git current) && git checkout -b $1 && git drop #"
example:
git generate pr1 will checkout to new branch pr1 and git drop
usually you'd use git generate and not git drop
here's what to put in .gitconfig, for me global config is at: C:\Users\<user>\.gitconfig
[alias]
    drop = "!GIT_SEQUENCE_EDITOR=\"sed -i '/^pick .\\{7\\} --p:/  s/^pick/drop/'\" git rebase -i --root #"
    generate = "!CURRENT=$(git current) && git checkout -b $1 && git drop #"
    revertP = "!HEADID=$(git rev-parse HEAD) && git revert --no-commit HEAD && git commit -m \"--p: revert\" -m \"This reverts commit $HEADID.\" #"
    revertID = "!git revert --no-edit $1 && git revertP #"
thanks to Git alias with positional parameters