Use-case: every time I want to move commit from one git branch to another I perform the following sequence of actions:
git checkout
branch-to-merge-into
git cherry-pick
target-commit
git push
git checkout
working-branch
That works fine with the only exception - every time I perform 'git checkout' git working directory content is changed (expected) and that causes my IDE (IntelliJ IDEA) to perform inner state update (because monitored file system sub-tree is modified externally). That really annoys especially in case of big number of small commits.
I see two ways to go:
I don't like the first approach because its possible to forget to move particular commit. The second one looks a bit... unnatural.
Basically, it would be perfect if I could say git 'move this commit from branch with name branchX to the branch branchX+1' without working directory update.
Question: is it possible to perform the above?
when you switch to a branch without committing changes in the old branch, git tries to merge the changes to the files in the new branch. If merging is done without any conflict, swithing branches will be successful and you can see the changes in the new branch.
No, it is not possible to move a commit between branches without changing the working directory. This is because you will eventually run into a conflict, at which point git pauses so you can fix the conflict. If your working directly did not represent that state, then you would not be able to fix the conflicts correctly.
If you look around, you will find a lot of other possible solutions to this problem on SO, but the underlying issue sounds like that your editor does not handle the files being changed out from underneath it. This is basically a fact of using git. So, either update the editor or move to something more suited for a git workflow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With