Sometimes during development I realise I should split up my work and commit a small fix separately - however, this is made difficult if I have work-in-progress uncommitted changes, and I am already on a branch with several commits.
Git appears to have the following options, none of which are ideal:
- Commit the change to the current branch. Cherry-pick it later when the oustanding changes are finished and committed.
- Clone a 2nd repository and copy/paste the changes in there.
- Stash the uncommitted changes. Switch, write the small fix, commit, push, switch back, unstash (seems long winded and requires realising the small fix needs a separate branch before writing it)
I think I would like something like:
- Commit "to new branch", specify base commit and branch name. This would create a new branch, commit the change(s), and optionally stay on the current branch including the outstanding changes, or switch to the new branch discarding unstaged changes.
Is there anything like this I can use? Is there a better way of doing all this?