How can I do rebase?


Questions, Explanations, Howtos

Spider Stomper

Posts: 200

Joined: Sunday, 11th May 2014, 11:26

Post Sunday, 21st April 2019, 15:39

How can I do rebase?

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?
Attachments
rebase.png
My work was marked with red circles.
rebase.png (118.79 KiB) Viewed 3159 times

Abyss Ambulator

Posts: 1193

Joined: Friday, 16th January 2015, 20:20

Post Sunday, 21st April 2019, 17:59

Re: How can I do rebase?

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.

Ziggurat Zagger

Posts: 5382

Joined: Friday, 25th November 2011, 07:36

Post Monday, 29th April 2019, 21:21

Re: How can I do rebase?

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.
User avatar

Zot Zealot

Posts: 982

Joined: Monday, 29th September 2014, 09:04

Post Tuesday, 30th April 2019, 00:01

Re: How can I do rebase?

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.

Ziggurat Zagger

Posts: 5382

Joined: Friday, 25th November 2011, 07:36

Post Tuesday, 30th April 2019, 20:07

Re: How can I do rebase?

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.

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.