[oi-dev] Pull request : how to get back on track (git lost)

Jim Klimov jimklimov at cos.ru
Sun Mar 20 23:35:53 UTC 2016

21 марта 2016 г. 0:06:15 CET, bentahyr at chez.com пишет:
>I have hard time to get through the git way of doing things right now. 
>So, I forked oi-userland, added components or changes to it and did a
>pull request.
>Ok, I understand that I should have done one component at a time.
>It seems that the git way of doing this is to create one branch per
>component which I haven't done.
>Now I have all my commits in oi/hipster and how can I reach the
>situation where I can pull request one component only ?
>Is branching per component the best way to make pull request ?
>Best regards.
>oi-dev mailing list
>oi-dev at openindiana.org

Yes, there are many schools of thought here, but imho branching per issue is preferred so you can work on several issues in parallel, especially in projects like this where changes can be big and reviews - long.

To branch-off now you can clone a separate copy of your github fork that, I assume has all your commits, to local workstation (just to not break stuff in your main workspace while you experiment).

Then `git log > file.txt` to save all changesets metadata (assuming you did not dump everything into one commit - otherwise 'git rebase -i upstream/oi/hipster` may be your friend to re-cut commits, where 'upstream' is a manualky added remote common repo of OpenIndiana userland). After you saved metadata, go `git reset HEAD~x` where 'x' is the number of commits you'd rollback on your own oi/hipster to get at the unchanged state of the upstream project. You might instead `git reset commithash`, i don't happen to use that syntax much.

Note that rewriting history of your branch will require to `git push -f` (and don't mix -f and --all to avoid surprises - forcepush just one branch you're certain needs it) when you feed it back to github, but later on you won't have conflicts when merging upstream development into your workspace.

Then as you have the 'vanilla upstream' state, `git checkout -b issueN` to branch off a component, and using your saved metadata - `git cherrypick commithash` to select relevant commits in order. When done, do `git checkout oi/hipster` and repeat this paragraph until you've sorted the commits.

Typos courtesy of K-9 Mail on my Samsung Android

More information about the oi-dev mailing list