I recently ran into a problem when I need to select multiple files to move to remote branches using git. In my specific use case, there is only one file created / modified in each individual commit, and I need to programmatically click the selected files (in their last state). I did a little research and found 2 tricks that came close to what I need to do:
- I can use cherry picking to select specific commits in a new branch and merge this branch into a remote master.
- I can use rebase -i to reorder the commits, I assume I can change the order so that the commits associated with these selected files are in front, and I can just click the last commit in this list.
For a cherry fence this is a bit confusing. I can create a new branch without all the dirty commits and select the file that is committed to this branch. However, if the file already exists in the branch, it always causes a conflict, which I have to fix manually, and not ideally.
For rebase -i, from what I read, I need to go to the interactive editor where I need to manually reorder the commits, and after that I can start git push to apply everything before commit-SHA (which is reordered). Not perfect, as I have to do manual work.
In general, I think the rebase was close to what I needed, but I could not find an easy way to do this programmatically. Can someone come up with some operations with git analogues that can accomplish my task?
git git-rebase cherry-pick
Xavier_Ex
source share