Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rebase --onto #2285

Open
pkernevez opened this issue Jan 19, 2025 · 6 comments
Open

Add support for rebase --onto #2285

pkernevez opened this issue Jan 19, 2025 · 6 comments

Comments

@pkernevez
Copy link

pkernevez commented Jan 19, 2025

Hi,

As explain in this ticket #126 it should be nice to add support for rebase --onto.
When working with a lot of stack branch it really efficient to use rebase --onto instead of cherry picking (more efficient in term of manual actions but also in term of conflict resolution).
This is a common need when working on big epics through several small feature branch and PR. In this case in conjunction with --update-ref all the bracnches build on top of the first are move at the same time.

In term of ui, I think it could be done by selecting a range (from::to) and right click on another commit (other).
In this case the associated git command should be:
git rebase --onto $other $from $to

We can also imagine to not start with a range but a single select commit (start) and right click on another commit (other).
In this case to command should be:
git rebase --onto $other $from $my_current_branch

@pkernevez pkernevez changed the title Add support for rebase onto Add support for rebase --onto Jan 19, 2025
@DanPristupov
Copy link
Contributor

I think you can use interactive rebase and drop the undesired commits (usually, the bottom ones).

@pkernevez
Copy link
Author

pkernevez commented Jan 20, 2025

No you can't for my use case.

There are several specific use cases for rebase onto, but I will focus on my main one:
You are working (alone) on several chained branches:

Image

You have to amend a commit a the first branch (let's say C1 becoming C1' in my example):

Image

You now need to rebase commit C2 (included) to C3 onto C1.
If you try to use a classical rebase, you will have to solve the conflict between C1 and C1' because C1 and C1' modify the same files/lines (of course it's just an amendment).
With `git rebase --update-ref --onto C1' C1 feat3'
Image

@DanPristupov
Copy link
Contributor

DanPristupov commented Jan 20, 2025

If you try to use a classical rebase, you will have to solve the conflict between C1 and C1' because C1 and C1' modify the same files/lines (of course it's just an amendment).

As I said, use IR to rebase on C1' and drop the bottom commit (C1).

@pkernevez
Copy link
Author

pkernevez commented Jan 20, 2025

I can't use (or I don't knowh how) --update-ref with an IR

@DanPristupov
Copy link
Contributor

No, Fork doesn't support --update-ref, but this is unrelated to --onto

@pkernevez
Copy link
Author

It's already 'supported' by fork when you change your git conf like that:

[rebase]
        updateRefs = true

Rebase onto is quite fastidious to use because we need to retrieve the 3 relevant commits manually, it should be nice to have them filled by fork UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants