It's not possible.
The changes you commit are related to the current working copy. If you want to commit to another branch it means that you could commit changes from your working copy, but base them from another copy state.
This is not a natural way of versioning your work, and this is why you need to make different steps (stash changes, checkout the branch, pop stash and commit) to accomplish it.
As for your specific use case, a simple way is to keep two copies of your work, one checked out at master
branch, and the other at pages
branch.
In the pages
working copy, add the master
copy as a remote repo.
- You commit pages on
master
- Pull from
master
on the pages
copy
- push to GitHub
- reset the master branch at its previous state.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…