Page 1 of 1

How can I do rebase?

PostPosted: Sunday, 21st April 2019, 15:39
by sdynet
I pull requests my commit, and I got the following comment.

'we tend to avoid merge commits so if you rebase your branch onto master and remove the merge commit, it'll make it easier for someone to eventually merge. (Feel free to rebase and force push to PR branches.)'

So I'm trying to rebase, but I'm afraid I've made a mistake. I'm working on sourcetree now. How can I do it without making a mistake?

Re: How can I do rebase?

PostPosted: Sunday, 21st April 2019, 17:59
by Airwolf
I don't know the GUI, but find the button for rebase and click it. It won't destroy any of your work. If you're lucky, it will automatically rebase your changes onto the current master. If you're unlucky, it will walk you through manually fixing anything that needs fixed.

Re: How can I do rebase?

PostPosted: Monday, 29th April 2019, 21:21
by tasonir
If everything is in one commit you can just checkout master, pull (just to ensure you're on the latest master), and then cherry-pick your commit onto master. Once you're on the right branch it's just:

git cherry-pick edddf12<rest of hash>

I've never quite figured out how much of the hash to use for the short hash stuff, so I just paste the full hash code.

Otherwise the only way I've done rebasing is when you push there's an checkbox for 'rebase instead of merge' and then I'll rebase for you. I'm not seeing the option for it today but I used it on a project a few years back. Not sure why this one isn't showing the same process, something might have changed in the mean time or this repository is different.

Re: How can I do rebase?

PostPosted: Tuesday, 30th April 2019, 00:01
by chequers
I've never quite figured out how much of the hash to use for the short hash stuff, so I just paste the full hash code.

You can use the shortest prefix which is unambiguous (eg no other commit in the repository has the same prefix). Git generally won't print <7 char short hashes though.

Re: How can I do rebase?

PostPosted: Tuesday, 30th April 2019, 20:07
by tasonir
I suppose that covers all possible cases, although it does mean you don't know ahead of time what length it would need to be. But 1) it's fairly easy to just copy/paste the full thing and 2) the odds of having two commits that start with the same 7/8 characters is already very small, anyways.